【发布时间】:2017-03-05 09:07:18
【问题描述】:
我需要检测我的应用何时被卸载。为此,我看到 logcat 发出 UNINSTALL_PACKAGE 意图,我只是将它添加到我现有的广播接收器中。但它只是没有抓住它,而我正在听的其他意图 TIME_TICK 完美地工作。为什么?
当前使用的代码:
private IntentFilter intentFilter;
static {
intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_TIME_TICK);
intentFilter.addAction(Intent.ACTION_UNINSTALL_PACKAGE);
}
private final BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(Intent.ACTION_UNINSTALL_PACKAGE) {
Log.e("App", "Uninstalling");
} else if (action.equals(Intent.ACTION_TIME_TICK){
// this works
}
}
};
【问题讨论】:
标签: java android uninstallation broadcast