我需要处理应用程序包的更改,我像一样编写我的mainfest
mainfest.xml
<receiver android:name="PackageChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REPLACED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
我的接收器类
public class PackageChangeReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("app changed thank you ");
// here i will handle each one as i like
//if(intent.getAction().equalsIgnoreCase("android.intent.action.PACKAGE_REMOVED"))
// do some thing etc
}
}
但我不工作,我安装,删除广播未通知
请帮我修一下感谢
确定
我编译了你的代码
添加后的工作
<action android:name="android.intent.action.PACKAGE_INSTALL" />
//为其他已卸载的应用程序工作,但不通过卸载此应用程序进行测试
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
到您的代码。
您需要包的权限
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />