Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find the package name which has been uninstalled when using Intent.ACTION_PACKAGE_REMOVED
    primarykey
    data
    text
    <p>I have an application which is keeping a log of internally developed applications installed on the device. Upon installation a broadcast receiver for Intent.PACKAGE_ADDED is invoked and records the package name using the following code:</p> <pre><code>public class NewInstallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); int uid = b.getInt(Intent.EXTRA_UID); String[] packages = context.getPackageManager().getPackagesForUid(uid); ApplicationService appService = new ApplicationService(context); appService.ApplicationInstalled(packages); } } </code></pre> <p>The problem I'm facing is when using a broadcast receiver for Intent.PACKAGE_REMOVED, all reference to the package via the unique Id (UID) comes back with null information (As you would expect, given its already been uninstalled). I have a temporary solution for the meantime, but its not very elegant, and for the next version I would like to have cleaner code. An example of how the code should work:</p> <pre><code>public class RemoveApplicationReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle b = intent.getExtras(); int uid = b.getInt(Intent.EXTRA_UID); String[] packages = context.getPackageManager().getPackagesForUid(uid); ApplicationService appService = new ApplicationService(context); appService.ApplicationRemoved(packages); } } </code></pre> <p>So to recap, the question is:</p> <p>How, after a program has been removed, can I reference the package name in a broadcast receiver for Intent.PACKAGE_REMOVED.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload