title: How to Refresh Android's Home Launcher?
body: <p>I've been writing a background service which enforces my client's security policies on company devices. When the service is first installed, i launch an activity so that initial setup data can be entered. After this, i disable the activity:</p>
  
  <pre><code>ComponentName componentToDisable = new ComponentName("com.acme.background","com.acme.background.FirstLaunch");
          getPackageManager().setComponentEnabledSetting(componentToDisable,
           PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
           PackageManager.DONT_KILL_APP);
  FirstLaunch.this.finish();
  </code></pre>
  
  <p>At this point, the temporary icon is still visible until the Home Launcher is refreshed/restarted. This can be quite awhile on some devices, and the issue i'm having is that users get confused and uninstall via the icon. I need to refresh the home launcher. Here is one method i've tried via reflection, which gives me the current home launcher and access to its methods. </p>
  
  <pre><code>PackageManager PM = getPackageManager();
  Intent home_intent = new Intent("android.intent.action.MAIN");
  home_intent.addCategory("android.intent.category.HOME");
  home_intent.addCategory("android.intent.category.DEFAULT");
  ComponentName cn = home_intent.resolveActivity(PM);
  Context foreignContext = createPackageContext("com.android.launcher", Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
  String clName = cn.getClassName();
  Class&lt;?&gt; test = foreignContext.getClassLoader().loadClass(clName);
  </code></pre>
  
  <p>I've tried firing methods and also nulling fields to get a refresh/restart, but it doesnt seem to work. Does anyone have a solution to refresh the appDrawer/Icons?</p>
  
  <p><B>EDIT:</B></p>
  
  <p>I've included code that i launch after a dialog is fired. Below is what i'm using:</p>
  
  <pre><code>PackageManager PM = getPackageManager();
  Intent home_intent = new Intent("android.intent.action.MAIN");
  home_intent.addCategory("android.intent.category.HOME");
  home_intent.addCategory("android.intent.category.DEFAULT");
  ComponentName cn = home_intent.resolveActivity(PM);
  String pkgName = cn.getPackageName();
  Intent intent;
  if (android.os.Build.VERSION.SDK_INT &gt;= 9) {                       
      Uri packageURI = Uri.parse("package:" + pkgName);
      intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", packageURI);
      startActivity(intent);
      FirstLaunch.this.finish();
      performCleanup();
  }  else  {
      //support for 2.1
      intent = new Intent(Intent.ACTION_VIEW); 
      intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); 
      intent.putExtra("com.android.settings.ApplicationPkgName", pkgName); 
      intent.putExtra("pkg", pkgName); 
      startActivity(intent);  
      FirstLaunch.this.finish();
      performCleanup();
  }
  </code></pre>