【发布时间】:2016-10-02 04:17:08
【问题描述】:
我是 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();
}
【问题讨论】:
-
您想跟踪应用何时卸载?遗憾的是,这并没有发生...... android.intent.action.PACKAGE_REMOVED 已被移动设备中存在的所有其他应用程序接收,期待您的
-
@therealprashant 谢谢。你能告诉我whatsapp和其他消息应用程序如何停止向未安装应用程序的用户发送通知吗?
-
不知道 Whatsapp ..那是一个完全不同的堆栈...但是关于其他人..他们使用 GCM ...在发送通知之前..GCM 会检查用户是否有其设备令牌是否针对该特定应用程序...如果不是,则 GCM 不会发送通知...stackoverflow.com/questions/22994409/…
标签: java android push-notification broadcastreceiver android-broadcast