Thursday 30 August 2012

Android Converter

String to Integer Convert:

String string;
int in=Integer.parseInt(string);

Integer to String Convert:

int in;
String str=Integer.toString(test);

Bitmap to drawable and vice-versa:


Drawable d = new BitmapDrawable(getResources(),bitmap);

Bitmap icon = BitmapFactory.decodeResource(context.getResources(),
                                           R.drawable.icon_resource);

Bitmap to Byte :

Bitmap bmp = intent.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();