I always see "E ActivityManager: Sending non-protected broadcast from system" in android 7. What does this mean?
Asked Answered
K

1

5

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);
    }
Koral answered 11/4, 2017 at 19:33 Comment(14)
Check Background Optimizations in this link: developer.android.com/about/versions/nougat/… Hope this helpsFagen
What is the actual action string? I doubt that it is "com.test.testApp.testIntent".Poi
@SnehPandya I am not using any of these CONNECTIVITY_ACTION , ACTION_NEW_PICTURE or ACTION_NEW_VIDEO. How does this apply to my issue?Koral
@Poi Action string is "com.testApp.savi.STATUS_CHANGE"Koral
:: shrug :: Try changing the name, particularly the STATUS_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 your targetSdkVersion rises to O or higher (or whatever O turns into once Android O ships in final form). You may wish to consider using something else.Poi
@Poi Thanks that worked.Koral
@Poi My app was never a system app. Why do I get this error. Also what are the different ways that I can make my app a system app.Koral
"Why do I get this error" -- a bug in Android, perhaps. What device or emulator are you using for testing this? "Also what are the different ways that I can make my app a system app" -- build your own custom ROM.Poi
@Poi I meant how can I make an android a system app? I know we can use "android.uid.system" in androidManifest.xml. Is there any other way to make an android app a system app?Koral
"Is there any other way to make an android app a system app?" -- no. And the only way you can use android.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.Poi
FWIW, I cannot reproduce your problem. Sending a broadcast with sendBroadcast(new android.content.Intent("com.testApp.savi.STATUS_CHANGE")); works just fine on Android 7.1, when I put that code in onCreate() of an activity. I do not get the error that you cited.Poi
@Poi I use this intent in a service rather than an activity.Koral
I do not get that crash when broadcasting it from an IntentService either. If you get a chance to create a reproducible test case, consider filing an issue.Poi
Can you make your app a system app and check if you get the same issue?Koral
A
2

This might help,

If you have in your AndroidManifest.xml declared "android:sharedUserId="android.uid.system", then declare the protected broadcast.

Reference : https://stackoverflow.com/a/50240471

Arachnoid answered 29/3, 2019 at 12:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.