broadcastreceiver

Android throw DeadObjectException with LOG: Transaction failed on small parcel; remote process probably died

£可爱£侵袭症+ 提交于 2019-11-29 04:18:05
07-22 04:38:07.933 1579 3338 E JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 352) 07-22 04:38:07.933 1579 3338 W BroadcastQueue: Can't deliver broadcast to com.android.systemui (pid 2160). Crashing it. 07-22 04:38:07.934 1579 3338 W BroadcastQueue: Failure sending broadcast Intent { act=android.intent.action.TIME_TICK flg=0x50000014 (has extras) } 07-22 04:38:07.934 1579 3338 W BroadcastQueue: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died 07-22 04:38:07.934 1579 3338 W BroadcastQueue: at android.os.BinderProxy.transactNative

Is it possible to write an Android broadcast receiver that detects when the phone wakes up?

旧城冷巷雨未停 提交于 2019-11-29 04:06:12
I want to figure out how to detect when the phone wakes up from being in the black screen mode and write a handler for that event. Is that possible? It seems like this would be something a Broadcast Receiver should handle? Or is there a better or more proper way? Jim Blackler If you have a Service that it active you can catch these events with registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // do something } }, new IntentFilter(Intent.ACTION_SCREEN_ON)); However this relies on having a perpetually running service which I have

Getting the caller ID in Android 9

对着背影说爱祢 提交于 2019-11-29 03:51:34
I have been using the following code in a BroadcastReceiver to get the caller ID of incoming calls: @Override public void onReceive(Context aContext, Intent aIntent) { String action = aIntent.getAction(); if (action==null) return; if (!action.equals("android.intent.action.PHONE_STATE")) return; String curState = aIntent.getStringExtra(TelephonyManager.EXTRA_STATE); if ((TelephonyManager.EXTRA_STATE_RINGING.equals(curState)) &&(TelephonyManager.EXTRA_STATE_IDLE.equals(oldState)))){ String incNumber = aIntent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); // do something here } oldState

How to know in BroadcastReceiver if App is running on foreground?

早过忘川 提交于 2019-11-29 03:47:59
I am working in application that needs make a synchronization every night. I use Alarm Manager that calls a BroadcastReceiver at the hour that I want. The problem is that I cant make a synchronization if the application is running in foreground to avoid losing data. So I need to know in Broadcast Receiver if the app is running in foreground to cancel this synchronization. I tried solutions that I found in StackOverflow: Checking if an Android application is running in the background But this parameter is always false in BroadcastReceiver, but true in activites. Can anyone tell me which is the

What is the integer value that gives a broadcast receiver highest priority?

本小妞迷上赌 提交于 2019-11-29 03:34:40
What is the integer value the gives a broadcast receiver the highest priority? <intent-filter android:priority="1"> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> Well, according to the documentation "The value must be an integer, such as "100". Higher numbers have a higher priority." So I'm guessing that any integer value is valid. And the highest priority possible would be the maximum integer that android allows, which is (2^31 - 1). EDIT The documentation has been updated, and it now explicitly states which priority values may be used by applications. The

Android Broadcast from Service To Activity

限于喜欢 提交于 2019-11-29 03:21:41
I am trying to send a Broadcast from a service out to an Activity. I can verify the broadcast is sent from within the service, but the Activity doesn't pick up anything. Here is the relevant service code: Intent i = new Intent(NEW_MESSAGE); i.putExtra(FriendInfo.USERNAME, StringUtils.parseBareAddress(message.getFrom())); i.putExtra(FriendInfo.MESSAGE, message.getBody()); i.putExtra("who", "1"); sendBroadcast(i); And the receiving end in the activity class: public class newMessage extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String action =

java.lang.InstantiationException: class has no zero argument constructor

僤鯓⒐⒋嵵緔 提交于 2019-11-29 02:49:47
I am trying to use a BroadcastReceiver as an inner class to track the network state but I got the exception in the title. What should I do to fix this problem? public class NetworkChangeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); final android.net.NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifi

Android - how to make my app default sms app programatically

£可爱£侵袭症+ 提交于 2019-11-29 02:44:41
I am developing an sms blocking app. Which is working fine up to Jelly-Bean. And its not working from Kitkat to Marshmallow. I searched on google and everyone recommending to take permission from user to make it default sms app of this phone by using . if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if(!Telephony.Sms.getDefaultSmsPackage(getApplicationContext()).equals(getApplicationContext().getPackageName())) { Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT); intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getApplicationContext().getPackageName())

How to block an incoming message in android?

为君一笑 提交于 2019-11-29 02:43:34
I am trying to develop an app in android which blocks an incoming sms. I have set the priority but its not blocking the incoming sms. I have used this.abortBroadcast() also but no result. import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.gsm.SmsMessage; import android.widget.Toast; @SuppressWarnings("deprecation") public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { this.abortBroadcast(); Bundle bundle = intent.getExtras();

Android. Launch app from Dialer

丶灬走出姿态 提交于 2019-11-29 02:24:17
This is what I have so far but nothing happens when I input this combination in dialer public class DialReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, final Intent intent) { if (intent.getAction().equals(android.content.Intent.ACTION_NEW_OUTGOING_CALL)) { String phoneNumber = intent.getExtras().getString( android.content.Intent.EXTRA_PHONE_NUMBER ); if(phoneNumber.equals("*#588637#")) { Intent intent1 = new Intent(context , Activity.class); intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK ); context.startActivity(intent1); } } } } and in androidmanifest