I am trying to send an intent from a non system app using the following function.
public static void sendIntent() {
if (null != _context) {
Intent intent = new Intent("com.test.testApp.testIntent");
intent.setPackage(_context.getPackageName());
_context.sendBroadcast(intent);
}
}
But I always see there is an error message from ActivityManager as below. The same intent broadcasting(app) works fine in andorid 6.0 but throws an error in android 7.1.1. I am required to change anything for android 7.1.1?
4-10 15:06:34.423 1615 2921 E ActivityManager: Sending non-protected broadcast com.test.testApp.testIntent from system 2886:com.test.testApp/u0a117 pkg com.test.testApp
In a ListFragment I register the receiver as follows:
@Override
public void onStart() {
super.onStart();
getActivity().registerReceiver((receiver),
new IntentFilter(com.test.testApp.testIntent));
TextView textDownload = (TextView) getActivity().findViewById(R.id.output);
textDownload.setVisibility(android.view.View.INVISIBLE);
}
"com.test.testApp.testIntent"
. – Poi:: shrug ::
Try changing the name, particularly theSTATUS_CHANGE
bit, in case there is some strange bug when Android examines action strings to see what can and cannot be sent. Also note that implicit broadcasts like this do not work on Android O, once yourtargetSdkVersion
rises toO
or higher (or whateverO
turns into once Android O ships in final form). You may wish to consider using something else. – Poiandroid.uid.system
is if your app is signed by the same signing key that signs the rest of the pre-installed apps, and that requires you to build a custom ROM. – PoisendBroadcast(new android.content.Intent("com.testApp.savi.STATUS_CHANGE"));
works just fine on Android 7.1, when I put that code inonCreate()
of an activity. I do not get the error that you cited. – PoiIntentService
either. If you get a chance to create a reproducible test case, consider filing an issue. – Poi