Android examples for App:App Information
gen App Main Icon
import java.io.File; import java.io.FileOutputStream; import java.util.List; import org.wolink.app.appcategory.Category.Items; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.PaintDrawable; import android.net.Uri; import android.os.Environment; public class Main{ public static void genAppMainIcon(Context context) { Bitmap bm = Bitmap.createBitmap(72, 72, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bm); Drawable d1 = context.getResources().getDrawable( R.drawable.icon_back);//from w w w. j av a2 s . c o m d1.setBounds(new Rect(0, 0, 72, 72)); d1.draw(canvas); d1 = context.getResources().getDrawable(R.drawable.default_folder); d1.setBounds(new Rect(0, 0, 72, 72)); d1.draw(canvas); byte[] bmBytes = CategoryInfo.flattenBitmap(bm); String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media File rootDir = Environment.getExternalStorageDirectory(); File file = new File(rootDir.getPath() + File.separator + "icon.png"); try { file.createNewFile(); FileOutputStream fos = new FileOutputStream(file); fos.write(bmBytes); fos.close(); } catch (Exception e) { } } } }