Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>As Steve H said you can't just use file:///data/data/com.droidstogo.boom1/files/parked.jpg for that. It's your application private directory and camera can't write there. You can use some SD card file for example - it's available for all.</p></li> <li><p>As stealthcopter said, intent extra is just MediaStore.EXTRA_OUTPUT without your package name.</p></li> <li><p>Not an issue just FYI. I guess none of the permissions you specified are actually required for this operation.</p></li> </ol> <p>Here's my code sample:</p> <pre><code>final int REQUEST_FROM_CAMERA=1; private File getTempFile() { //it will return /sdcard/image.tmp return new File(Environment.getExternalStorageDirectory(), "image.tmp"); } private void getPhotoClick() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(getTempFile())); startActivityForResult(intent, REQUEST_FROM_CAMERA); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_FROM_CAMERA &amp;&amp; resultCode == RESULT_OK) { InputStream is=null; File file=getTempFile(); try { is=new FileInputStream(file); } catch (FileNotFoundException e) { e.printStackTrace(); } //On HTC Hero the requested file will not be created. Because HTC Hero has custom camera //app implementation and it works another way. It doesn't write to a file but instead //it writes to media gallery and returns uri in intent. More info can be found here: //http://stackoverflow.com/questions/1910608/android-actionimagecapture-intent //http://code.google.com/p/android/issues/detail?id=1480 //So here's the workaround: if(is==null){ try { Uri u = data.getData(); is=getContentResolver().openInputStream(u); } catch (FileNotFoundException e) { e.printStackTrace(); } } //Now "is" stream contains the required photo, you can process it DoSomeProcessing(is); //don't forget to remove the temp file when it's not required. } } </code></pre>
 

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