@CalledByNative public static Bitmap generateHomeScreenIcon(Context context,String url,int red,int green,int blue){
  ActivityManager am=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  final int outerSize=am.getLauncherLargeIconSize();
  final int iconDensity=am.getLauncherLargeIconDensity();
  Bitmap bitmap=null;
  try {
    bitmap=Bitmap.createBitmap(outerSize,outerSize,Bitmap.Config.ARGB_8888);
  }
 catch (  OutOfMemoryError e) {
    Log.w(TAG,"OutOfMemoryError while trying to draw bitmap on canvas.");
    return null;
  }
  Canvas canvas=new Canvas(bitmap);
  int padding=(int)(GENERATED_ICON_PADDING_RATIO * outerSize);
  Rect outerBounds=new Rect(0,0,outerSize,outerSize);
  Bitmap bookmarkWidgetBg=getBitmapFromResourceId(context,R.mipmap.bookmark_widget_bg,iconDensity);
  Paint paint=new Paint(Paint.FILTER_BITMAP_FLAG);
  canvas.drawBitmap(bookmarkWidgetBg,null,outerBounds,paint);
  int innerSize=outerSize - 2 * padding;
  int cornerRadius=Math.round(ICON_CORNER_RADIUS_RATIO * outerSize);
  int fontSize=Math.round(GENERATED_ICON_FONT_SIZE_RATIO * outerSize);
  int color=Color.rgb(red,green,blue);
  RoundedIconGenerator generator=new RoundedIconGenerator(innerSize,innerSize,cornerRadius,color,fontSize);
  Bitmap icon=generator.generateIconForUrl(url);
  if (icon == null)   return null;
  canvas.drawBitmap(icon,padding,padding,null);
  return bitmap;
}

@ CalledByNative public static Bitmap generateHomeScreenIcon ( Context context , String url , int red , int green , int blue ) { ActivityManager am = ( ActivityManager ) context . getSystemService ( Context . ACTIVITY_SERVICE ) ; final int outerSize = am . getLauncherLargeIconSize ( ) ; final int iconDensity = am . getLauncherLargeIconDensity ( ) ; Bitmap bitmap = null ; try { bitmap = Bitmap . createBitmap ( outerSize , outerSize , Bitmap . Config . ARGB_8888 ) ; } catch ( OutOfMemoryError e ) { Log . w ( TAG , "OutOfMemoryError while trying to draw bitmap on canvas." ) ; return null ; } Canvas canvas = new Canvas ( bitmap ) ; int padding = ( int ) ( GENERATED_ICON_PADDING_RATIO * outerSize ) ; Rect outerBounds = new Rect ( 0 , 0 , outerSize , outerSize ) ; Bitmap bookmarkWidgetBg = getBitmapFromResourceId ( context , R . mipmap . bookmark_widget_bg , iconDensity ) ; Paint paint = new Paint ( Paint . FILTER_BITMAP_FLAG ) ; canvas . drawBitmap ( bookmarkWidgetBg , null , outerBounds , paint ) ; int innerSize = outerSize - 2 * padding ; int cornerRadius = Math . round ( ICON_CORNER_RADIUS_RATIO * outerSize ) ; int fontSize = Math . round ( GENERATED_ICON_FONT_SIZE_RATIO * outerSize ) ; int color = Color . rgb ( red , green , blue ) ; RoundedIconGenerator generator = new RoundedIconGenerator ( innerSize , innerSize , cornerRadius , color , fontSize ) ; Bitmap icon = generator . generateIconForUrl ( url ) ; if ( icon == null ) return null ; canvas . drawBitmap ( icon , padding , padding , null ) ; return bitmap ; }
generates a generic icon to be used in the launcher . this is just a rounded rectangle with a letter in the middle taken from the website ' s domain name .
