Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在系统应用程序中使用sendBroadcast_Android - Fatal编程技术网

Android 在系统应用程序中使用sendBroadcast

Android 在系统应用程序中使用sendBroadcast,android,Android,我无法从作为系统应用程序加载到自定义rom中的应用程序(使用清单中的android:sharedUserId=“android.uid.system”)发送广播 我遇到的问题是在尝试执行简单的sendBroadcast时: Intent newIntent = new Intent(intent.getExtras().getString(BUNDLE_ACTION_TO_REPLY_ON)); newIntent.putExtra(BUNDLE_FILE_URI, bitmapFile.get

我无法从作为系统应用程序加载到自定义rom中的应用程序(使用
清单中的
android:sharedUserId=“android.uid.system”
)发送
广播

我遇到的问题是在尝试执行简单的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);
我在Logcat中收到以下警告:

在没有合格用户的情况下调用系统进程中的方法

warnIfCallingFromSystemProcess()
过程中,这是由泵输出的


有人知道原因吗(如果我需要“修复”它)?

使用下面的函数而不是
sendBroadcast(Intent-Intent)

例如:

context.sendBroadcastAsUser(newIntent, new UserHandle(UserHandle.USER_CURRENT));

能否显示初始化上下文的位置?它作为广播接收器的一部分传入(
public void onReceive(final context context,final Intent Intent)
)此BroadcastReceiver是您的系统应用程序?应用程序中有一个BroadcastReceiver是:)不幸的是,该项目已降低了我的优先级,因此我没有机会尝试@sMiLo的答案,这看起来是一个不错的选择。这不能由未预装的应用程序使用,请阅读此处:@Mat:Yes。它仅用于系统应用程序。什么是
UserHandle.USER\u CURRENT
参数?
Process.myUserHandle()
而不是
new UserHandle(UserHandle.USER\u CURRENT)
为我做了这项工作您不需要新的UserHandle对象,只需使用
UserHandle.CURRENT
context.sendBroadcastAsUser(newIntent, new UserHandle(UserHandle.USER_CURRENT));