Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I came across this problem when working with HTC camera too.</p> <p>From what I recall HTC / Sense handles the return photo slightly differently, here's some pseudo of how I did it to hopefully handle the two variants of handling photos..</p> <pre><code>public static void StartCameraActivity() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null); // Create the directory if it's not there File photoDir = new File(Environment.getExternalStorageDirectory() + "/.pics/"); photoDir.mkdirs(); // Construct the file.. String fileName = File.separator + ".pics/photo" + String.valueOf(System.currentTimeMillis()) + ".jpg"; File file = new File(Environment.getExternalStorageDirectory(), fileName); // Create the intent and remember the place we asked for the file to be placed intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, LinearLayout.VERTICAL ); _outputFileUri = Uri.fromFile(file); context.getActivity().startActivityForResult(intent, 1); } </code></pre> <hr> <pre><code> Bitmap bm = null; BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = SAMPLE_SIZE; try { bm= (Bitmap) data.getExtras().get("data"); FileOutputStream out = new FileOutputStream(_outputFileUri.getPath()); bm.compress(Bitmap.CompressFormat.JPEG, 100, out); } catch (NullPointerException ex) { bm = OtherImageProcessing(options); } catch (Exception e) { throw new Exception("Problem occured.", e); } </code></pre> <hr> <pre><code>public static Bitmap OtherImageProcessing(BitmapFactory.Options options) throws Exception { Bitmap bm = null; try { FileInputStream fis = new FileInputStream(_outputFileUri.getPath()); BufferedInputStream bis = new BufferedInputStream(fis); bm = BitmapFactory.decodeStream(bis, null, options); // cleaning up fis.close(); bis.close(); } catch (Exception e) { throw new Exception("Problem", e); } return bm; } </code></pre> <p>Hope that helps...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload