我是android的新手我想知道如何在卸载应用程序后禁用接收通知,是否有任何事件或某些东西来检测该应用程序是否已卸载? 我试过这个但不适合我
if(intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {
Intent i = new Intent(context,BootReceiver.class);
Identifier = i.getStringExtra("Recognition_flag");
serverUrl = Constants.urlAll + "uninstall.php";
LongOperation serverRequest = new LongOperation();
// serverRequest.execute(serverUrl, user, pass,
// deviceIMEI);
serverRequest.execute(serverUrl, user);
GCMRegistrar.setRegisteredOnServer(context, true);
Log.e(" BroadcastReceiver ", "onReceive called " + " PACKAGE_REMOVED ");
Toast.makeText(context, " onReceive !!!! PACKAGE_REMOVED", Toast.LENGTH_LONG).show();
}
// when package installed
else if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
Log.e(" BroadcastReceiver ", "onReceive called " + "PACKAGE_ADDED");
Toast.makeText(context, " onReceive !!!!." + "PACKAGE_ADDED", Toast.LENGTH_LONG).show();
}
答案 0 :(得分:1)
您无法以任何简单的方式检测Android上的应用卸载。广播 移除应用后, android.intent.action.PACKAGE_REMOVED 会发送到移动但中的所有应用。
当我的公司在卸载应用程序时已经跟踪了一些方法,但这是非常棘手和深刻的。