本文介绍了PACKAGE_ADDED的BroadcastReceiver不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在清单中注册的广播接收器:
I have a broadcast receiver registered in Manifest:
<application ...>
<receiver android:name="com.some.pkg.NewAppReceiver" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
</intent-filter>
</receiver>
</appcication>
和接收器:
public class NewAppReceiver extends BroadcastReceiver {
private static final String TAG = "NewAppReceiver";
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Intent: " + intent.getAction());
}
}
和接收没事的时候我安装 APK 手动或从 Android Market的。为什么呢?
And nothing is received when I install APK manually or from the Android Market. Why?
推荐答案
你运行一个包含此的BroadcastReceiver安装其他应用程序之前,应用程序?
Did you run the app that contains this broadcastReceiver before installing the other apps?
开始在一些API版本,broadcastReceivers不会直到你执行应用程序的工作。把活动并执行它。
Starting at some API version, broadcastReceivers will not work till you execute the app. Put an activity and execute it.
另外,不要忘记添加以下到BroadcastReceiver的:
Also , don't forget to add the following into the broadcastReceiver:
<data android:scheme="package" />
这篇关于PACKAGE_ADDED的BroadcastReceiver不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!