Monday, 4 February 2013

Send application crash report via email in Android

This is application crash reporting for android. It will give all the unhandled exception detail on developer mail that cause crash application because of memory reason etc.

Developers can use this in their projects to know the unhandled exception detail and as well as device detail.

To download complete project, please click here.

Monday, 24 December 2012

Save Bitmap in Internal and External Memory in Android

Hi folks! I am here sharing a code to save the bitmap in Internal and External storage in Android.

/** * Method to save bitmap into internal memory * @param image and context */ public boolean saveImageToInternalStorage(Bitmap image,Context context) { try { FileOutputStream fos = context.openFileOutput("photo.jpg", Context.MODE_WORLD_READABLE); image.compress(Bitmap.CompressFormat.JPEG, 100, fos); // 100 means no compression, the lower you go, the stronger the compression fos.close(); return true; } catch (Exception e) { Log.e("saveToInternalStorage()", e.getMessage()); } return false; }

 * Method to save bitmap into external storage
* @param image
* @return true if save success otherwise false
public void saveImageToExternalStorage(Bitmap image) {
String fullPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
File dir = new File(fullPath);
if (!dir.exists()) {
OutputStream fOut = null;
File file = new File(fullPath, "photo1.png");


fOut = new FileOutputStream(file);
// 100 means no compression, the lower you go, the stronger the compression
image.compress(Bitmap.CompressFormat.PNG, 100, fOut);
catch (Exception e)
Log.e("saveToExternalStorage()", e.getMessage());

Check whether device is Tablet Programatically in Android

Hi folks! I am here sharing a simple code where you check your Android device is tablet or phone at run time programmatically.

* To check device is tablet or not.
* @param context
* @return true if device is tablet
public static boolean isTablet(Context context) {
      boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
      boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
   return (xlarge || large);

Share Image with text on Twitter , Facebook and Email etc. in Android

Hi folks, I am here sharing a code which you can use in your project to share the text with image on Twitter, Facebook, Email.

But in case of facebook you can not share the text on facebook using Intent but you can share the link on facebook and rest twitter/email you can share the text plus image perfectly.

If you are looking to share the text not link then in case of facebook you have to use the Facebook SDK.

1) For attaching image on gmail with text use below code.

File filePath = context.getFileStreamPath("vmphoto.jpg");

2) For sharing image on facebook

File filePath = context.getFileStreamPath("vmphoto.jpg");

3) For sharing image with text on twitter

File filePath = context.getFileStreamPath("vmphoto.jpg");

* To share photo with text on facebook , twitter and email etc.@param nameApp
* @param nameApp
* @param imagePath
* /

void share(String nameApp, String imagePath) {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
    if (!resInfo.isEmpty()){
        for (ResolveInfo info : resInfo) {
            Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND);
            targetedShare.setType("image/jpeg"); // put here your mime type
            if (info.activityInfo.packageName.toLowerCase().contains(nameApp) || {
                targetedShare.putExtra(Intent.EXTRA_SUBJECT, "Sample Photo");
             targetedShare.putExtra(Intent.EXTRA_TEXT,"This photo is created by App Name");
                targetedShare.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)) );
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Select app to share");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
catch(Exception e){
     Log.v("VM","Exception while sending image on" + nameApp + " "+  e.getMessage());