【发布时间】:2015-03-21 01:01:55
【问题描述】:
我在服务中使用下面的代码运行后台来获取预卸载事件,但它正在调用我不需要的所有应用程序。我只想要我的应用程序的事件。
示例: 我的应用程序“A” 其他应用程序“B”、“C”....
当尝试卸载“A”应用程序时,我想要预卸载事件。
但当前代码为“B”、“C”等其他应用程序返回预卸载事件.....
// get the info from the currently running task
List<ActivityManager.RunningTaskInfo> taskInfo = mActivityManager
.getRunningTasks(10);
String activityName = taskInfo.get(0).topActivity
.getClassName();
Log.d("topActivity", "CURRENT Activity ::" + activityName);
if (activityName
.equals("com.android.packageinstaller.UninstallerActivity")) {
// User has clicked on the Uninstall button under the Manage
// Apps settings
// do whatever pre-uninstallation task you want to perform
Toast.makeText(getApplicationContext(),
"warning!!! You are not supposed to uninstall",
Toast.LENGTH_SHORT).show();
if (!mIntimation) {
startIntimate();
mIntimation = true;
}
} else {
mIntimation = false;
}
谢谢。
【问题讨论】:
-
你不能,不是为了你自己。如果您可以自行卸载,那将是恶意软件的宝库。
标签: android performance android-intent android-activity