Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try This</p> <p>Start Camera like this, use this code in onCreate method.</p> <pre><code> Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); String filePath = Environment.getExternalStorageDirectory() + ""; filePath = filePath + File.separator + "temp_img.jpg"; File f = new File(filePath); try { if (!f.exists()) { f.createNewFile(); } } catch (Exception e) { e.printStackTrace(); } Uri uri = Uri.fromFile(f); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, 0); </code></pre> <p>onActivityResult method.</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); Uri currImageURI = null; if (resultCode == Activity.RESULT_OK) { if (data != null) { currImageURI = data.getData(); } if (currImageURI == null) { String filePath = Environment.getExternalStorageDirectory() + ""; filePath = filePath + File.separator + "temp_img.jpg"; File f = new File(filePath); currImageURI = Uri.fromFile(f); } ContentResolver cr = getContentResolver(); Bitmap bitmap; try { bitmap = android.provider.MediaStore.Images.Media.getBitmap(cr, currImageURI); iv.setImageBitmap(bitmap); } catch (Exception e) { Log.e("Camera", e.toString()); } } } </code></pre> <p>And Make sure to initialize iv in onCreate.</p> <pre><code>iv=(ImageView) findViewById(R.id.imageView1); </code></pre> <p>In Last add permission to write file on sdcard.</p> <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; </code></pre>
    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.
 

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