android – How does Dolphin web browser get notified when it's being uninstalled?-ThrowExceptions

Exception or error:

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?

How to solve:

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?

###

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?

###

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
}

Leave a Reply

Your email address will not be published. Required fields are marked *