Capturing images crashing on HTC devices
<p>Hi I am developing a app that captures images and email it capturing the images is working fine on Samsung galaxy and Sony Ericsson xperia but it's not working on HTC devices anyone know a reason why ?? here is my code for capturing images </p>

<pre><code>try {
    String fileName = Image_name+".jpg";
    //create parameters for Intent with filename
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, fileName);
    values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");
    //imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState)
    outuri = getContentResolver().insert(
    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    //outuri = Uri.fromFile(photo);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outuri);
    cameraIntent.putExtra("return-data", true);
    startActivityForResult(cameraIntent, 2);
} catch (Exception e) {
    Toast.makeText(preview.this, ""+e, Toast.LENGTH_LONG).show();
}
</code></pre>

<p>and here is code that I use to retrieve images </p>

<pre><code>path = convertImageUriToFile(outuri, preview.this).getAbsolutePath();
arr.add(path);
try {
    bitmap = getImage(path);
    public static File convertImageUriToFile (Uri imageUri, Activity activity)  {
        Cursor cursor = null;
        try {
            String [] proj={MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID, MediaStore.Images.ImageColumns.ORIENTATION};
            cursor = activity.managedQuery(imageUri, proj, // Which columns to return
                    null,       // WHERE clause; which rows to return (all rows)
                    null,       // WHERE clause selection arguments (none)
                    null); // Order-by clause (ascending by name)
            int file_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            int orientation_ColumnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.ImageColumns.ORIENTATION);
            if (cursor.moveToFirst()) {
                String orientation =  cursor.getString(orientation_ColumnIndex);
                return new File(cursor.getString(file_ColumnIndex));
            }
            return null;
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    public Bitmap getImage(String path) throws IOException
    {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(path, options);
        Bitmap targetBitmap=null;
        int srcWidth = options.outWidth;
        int srcHeight = options.outHeight;
        int[] newWH =  new int[2];
        newWH[0] = 1024;
        newWH[1] = (1024*srcHeight)/srcWidth;

        int inSampleSize = 1;
        while(srcWidth / 2 &gt; newWH[0]){
            srcWidth /= 2;
            srcHeight /= 2;
            inSampleSize *= 2;
        }
//      float desiredScale = (float) newWH[0] / srcWidth;
        // Decode with inSampleSize
        options.inJustDecodeBounds = false;
        options.inDither = false;
        options.inSampleSize = inSampleSize;
        options.inScaled = false;
        options.inPreferredConfig = Bitmap.Config.ARGB_8888;
        Bitmap sampledSrcBitmap = BitmapFactory.decodeFile(path,options);
        ExifInterface exif = new ExifInterface(path);
        String s=exif.getAttribute(ExifInterface.TAG_ORIENTATION);
        System.out.println("Orientation&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;"+s);
        Matrix matrix = new Matrix();
        float rotation = rotationForImage(preview.this, Uri.fromFile(new File(path)));
        if (rotation != 0f) {
            matrix.preRotate(rotation);
        }
        int newh = ( w * sampledSrcBitmap.getHeight() ) /sampledSrcBitmap.getWidth();
        Bitmap r=Bitmap.createScaledBitmap(sampledSrcBitmap, w, newh, true);
        Bitmap resizedBitmap = Bitmap.createBitmap(
                r, 0, 0, w, newh, matrix, true);

        return resizedBitmap;
    }
}
</code></pre>
