1 package com.android.launcher3;
2 
3 import android.content.BroadcastReceiver;
4 import android.content.Context;
5 import android.content.Intent;
6 
7 public class PackageChangedReceiver extends BroadcastReceiver {
8     @Override
onReceive(final Context context, Intent intent)9     public void onReceive(final Context context, Intent intent) {
10         final String packageName = intent.getData().getSchemeSpecificPart();
11 
12         if (packageName == null || packageName.length() == 0) {
13             // they sent us a bad intent
14             return;
15         }
16         // in rare cases the receiver races with the application to set up LauncherAppState
17         LauncherAppState.setApplicationContext(context.getApplicationContext());
18         LauncherAppState app = LauncherAppState.getInstance();
19         WidgetPreviewLoader.removePackageFromDb(app.getWidgetPreviewCacheDb(), packageName);
20     }
21 }
22