public static void preloadIcon(Context context,ComponentName componentName,Bitmap icon,int dpi){
  try {
    PackageManager packageManager=context.getPackageManager();
    packageManager.getActivityIcon(componentName);
    return;
  }
 catch (  PackageManager.NameNotFoundException e) {
  }
  final String key=componentName.flattenToString();
  FileOutputStream resourceFile=null;
  try {
    resourceFile=context.openFileOutput(getResourceFilename(componentName),Context.MODE_PRIVATE);
    ByteArrayOutputStream os=new ByteArrayOutputStream();
    if (icon.compress(android.graphics.Bitmap.CompressFormat.PNG,75,os)) {
      byte[] buffer=os.toByteArray();
      resourceFile.write(buffer,0,buffer.length);
    }
 else {
      Log.w(TAG,"failed to encode cache for " + key);
      return;
    }
  }
 catch (  FileNotFoundException e) {
    Log.w(TAG,"failed to pre-load cache for " + key,e);
  }
catch (  IOException e) {
    Log.w(TAG,"failed to pre-load cache for " + key,e);
  }
 finally {
    if (resourceFile != null) {
      try {
        resourceFile.close();
      }
 catch (      IOException e) {
        Log.d(TAG,"failed to save restored icon for: " + key,e);
      }
    }
  }
}

public static void preloadIcon ( Context context , ComponentName componentName , Bitmap icon , int dpi ) { try { PackageManager packageManager = context . getPackageManager ( ) ; packageManager . getActivityIcon ( componentName ) ; return ; } catch ( PackageManager . NameNotFoundException e ) { } final String key = componentName . flattenToString ( ) ; FileOutputStream resourceFile = null ; try { resourceFile = context . openFileOutput ( getResourceFilename ( componentName ) , Context . MODE_PRIVATE ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; if ( icon . compress ( android . graphics . Bitmap . CompressFormat . PNG , 75 , os ) ) { byte [ ] buffer = os . toByteArray ( ) ; resourceFile . write ( buffer , 0 , buffer . length ) ; } else { Log . w ( TAG , "failed to encode cache for " + key ) ; return ; } } catch ( FileNotFoundException e ) { Log . w ( TAG , "failed to pre-load cache for " + key , e ) ; } catch ( IOException e ) { Log . w ( TAG , "failed to pre-load cache for " + key , e ) ; } finally { if ( resourceFile != null ) { try { resourceFile . close ( ) ; } catch ( IOException e ) { Log . d ( TAG , "failed to save restored icon for: " + key , e ) ; } } } }
pre - load an icon into the persistent cache . < p > queries for a component that does not exist in the package manager will be answered by the persistent cache .
