Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use this. It would help you.</p> <pre><code>public class LoadImagesFromSDCard extends AsyncTask&lt;String, Void, Void&gt; { private ProgressDialog Dialog = new ProgressDialog(CameraPhotoCapture.this); Bitmap mBitmap; protected void onPreExecute() { /****** NOTE: You can call UI Element here. *****/ //UI Element Dialog.setMessage("Loading image from Sdcard.."); Dialog.show(); } // Call after onPreExecute method protected Void doInBackground(String... urls) { Bitmap bitmap = null; Bitmap newBitmap = null; Uri uri = null; try { /** Uri.withAppendedPath Method Description * Parameters * baseUri Uri to append path segment to * pathSegment encoded path segment to append * Returns * a new Uri based on baseUri with the given segment appended to the path */ uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + urls[0]); /************** Decode an input stream into a bitmap. *********/ bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri)); if (bitmap != null) { /********* Creates a new bitmap, scaled from an existing bitmap. ***********/ newBitmap = Bitmap.createScaledBitmap(bitmap, 170, 170, true); bitmap.recycle(); if (newBitmap != null) { mBitmap = newBitmap; } } } catch (IOException e) { //Error fetching image, try to recover /********* Cancel execution of this task. **********/ cancel(true); } return null; } protected void onPostExecute(Void unused) { // NOTE: You can call UI Element here. // Close progress dialog Dialog.dismiss(); if(mBitmap != null) showImg.setImageBitmap(mBitmap); } } </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.
    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