我的问题是: 如何检测用户何时取消安装apk? 我要安装的代码是:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
BroadcastReceiver br = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// detect if user install apk
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addCategory(Intent.CATEGORY_DEFAULT);
filter.addDataScheme("package");
context.startActivity(intent);
所以我可以检测用户何时安装/更新包但无法检测用户何时取消安装apk活动。怎么解决这个?