How does Dolphin web browser get notified when it's being uninstalled?

会有一股神秘感。 提交于 2019-11-29 02:11:59

问题


Background

It might be useful for apps to allow to ask the user to answer why it was decided to uninstall them.

The problem

It seems that the Dolphin web browser app (and "everything me launcher") somehow managed to bypass it, and now it shows a webpage (on the default web browser) each time the app is being uninstalled.

This happens even if I uninstall using ADB.

As a user, I really hate it, but it's still interesting since as far as I know, apps can't get intents for the uninstallation of themselves.

Question

How could it be? How did they manage to overcome this?

Is this a hack?


回答1:


Maybe the app has a background service which checks the foreground app when it's own onDestroy() callback is fired, and if the foreground app is the uninstalling activity of android Package installer, it launch a new intent for the webpage?




回答2:


My guess is that they're using ACTION_PACKAGE_REMOVED. http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED Either that, or Robin Hood and Frei Tuck method, where each one listens to broadcasts events from the other.
Just a guess, but will look into it.
This might be an option: How can an app detect that it's going to be uninstalled?




回答3:


Please try to get the top activity in the task via ActivityManager, and check if it is the uninstall activity.

Core code:

ComponentName topActivity = mActivityManager.getRunningTasks(1).get(0).topActivity;
String packageName = topActivity.getPackageName();
String className = topActivity.getClassName();
Log.v(TAG, "packageName" + packageName);
Log.v(TAG, "className" + className);

if ("com.android.packageinstaller".equals(packageName)
    && "com.android.packageinstaller.UninstallerActivity".equals(className)) {
//Do anything you want here
}


来源:https://stackoverflow.com/questions/18440293/how-does-dolphin-web-browser-get-notified-when-its-being-uninstalled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!