本文介绍了广播接收器的Package_Install不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@覆盖公共无效的onReceive(上下文的背景下,意图意图){ // TODO自动生成方法存根 Toast.makeText(背景下,包接,Toast.LENGTH_SHORT).show(); Log.d(包安装,包安装); 字符串行动= intent.getAction(); 如果(action.equals(intent.ACTION_PACKAGE_INSTALL)) { Toast.makeText(背景下,包增加,Toast.LENGTH_SHORT).show(); Log.d(包安装,包安装); }}
//我的清单文件:
<接收机器人:名字=com.example.anotherbroadcastreceiverexample.MyReceiver机器人:启用=真正的> <意向滤光器><作用机器人:名字=android.intent.action.PACKAGE_INSTALL/>< /意向滤光器> < /接收器>解决方案
你能不能尝试修改你的表现在以下方式:
<意向滤光器> <作用机器人:名字=android.intent.action.PACKAGE_INSTALL/> <作用机器人:名字=android.intent.action.PACKAGE_ADDED/> <数据机器人:计划=包/>&所述; /意图滤光器>更新:
检查不检查PACKAGE_INSTALL行动PACKAGE_ADDED。
@Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub Toast.makeText(context, "Package Received", Toast.LENGTH_SHORT).show(); Log.d("Package Installing", "Package Installing"); String action=intent.getAction(); if(action.equals(intent.ACTION_PACKAGE_INSTALL)) { Toast.makeText(context, "Package Added", Toast.LENGTH_SHORT).show(); Log.d("Package INstalling", "Package Installed"); } }//My Manifest File:
<receiver android:name="com.example.anotherbroadcastreceiverexample.MyReceiver" android:enabled="true"> <intent-filter><action android:name="android.intent.action.PACKAGE_INSTALL"/></intent-filter> </receiver>解决方案
Could you try to modify your Manifest in the following way:
<intent-filter> <action android:name="android.intent.action.PACKAGE_INSTALL" /> <action android:name="android.intent.action.PACKAGE_ADDED" /> <data android:scheme="package"/> </intent-filter>UPDATE:
Check not PACKAGE_INSTALL check action PACKAGE_ADDED.
更多推荐
广播接收器的Package
发布评论