【发布时间】:2013-04-15 11:15:51
【问题描述】:
我无法从作为系统应用程序加载到自定义 rom 中的应用程序发送 Broadcast(在 Manifest 中使用 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 中收到此警告:
Calling a method in the system process without a qualified user
这是由ContextImpl.java 在warnIfCallingFromSystemProcess() 进程中抽出的。
有人知道原因吗(如果我需要“修复”它)?
【问题讨论】:
-
你能说明你在哪里初始化上下文吗?
-
它作为广播接收器的一部分传入 (
public void onReceive(final Context context, final Intent intent)) -
这个 BroadcastReceiver 是你的系统应用吗?
-
应用中有一个 BroadcastReceiver 是的 :)
-
不幸的是,该项目已从我的优先级列表中移出,因此我没有机会尝试@sMiLo 的答案,这看起来是个不错的选择。
标签: android