I'm having trouble sending a Broadcast
from an app which is be loaded in a custom rom as a system app (Using android:sharedUserId="android.uid.system"
in the Manifest
).
The problem I'm getting is when trying to perform a simple sendBroadcast:
Intent newIntent = new Intent(intent.getExtras().getString(BUNDLE_ACTION_TO_REPLY_ON));
newIntent.putExtra(BUNDLE_FILE_URI, bitmapFile.getAbsolutePath());
newIntent.putExtra(BUNDLE_REPLY_WIDTH, width);
newIntent.putExtra(BUNDLE_REPLY_HEIGHT, height);
newIntent.putExtra(BUNDLE_REPLY_EXTRA, extra);
context.sendBroadcast(newIntent);
I'm getting this warning in Logcat:
Calling a method in the system process without a qualified user
This is being pumped out by ContextImpl.java
in the warnIfCallingFromSystemProcess()
process.
Does anybody know why (and if I need to "fix" it)?
Android provides three ways for apps to send broadcast: The sendOrderedBroadcast(Intent, String) method sends broadcasts to one receiver at a time. As each receiver executes in turn, it can propagate a result to the next receiver, or it can completely abort the broadcast so that it won't be passed to other receivers.
An application listens for specific broadcast intents by registering a broadcast receiver in AndroidManifest. xml file. Consider we are going to register MyReceiver for system generated event ACTION_BOOT_COMPLETED which is fired by the system once the Android system has completed the boot process.
As an Android developer, you'll often run into the scenario where you need to perform tasks and display notifications for your app in the background. To retain battery power on our users device we are going to run background tasks using a broadcast receiver.
Use below function instead of sendBroadcast(Intent intent)
.
void sendBroadcastAsUser(Intent intent, UserHandle user)
for example:
context.sendBroadcastAsUser(newIntent, new UserHandle(UserHandle.USER_CURRENT));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With