Get Image From Gallary using MediaStore Content URI

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Get Image From Gallary using MediaStore Content URI

Postby bins1984 » Tue May 04, 2010 7:28 am

HI

Here i write how to access an image from Gallary in our application

here i paste the sample code for that

to start Gallary Activity from our application

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  Intent Gallaryintent = new Intent();
  2.  
  3.         Gallaryintent.setAction(Intent.ACTION_PICK);
  4.  
  5.         Gallaryintent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
  6.  
  7.         startActivityForResult(Gallaryintent, constants.ACT_IMAGEREQUESTCODE);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


here is code to get the image Uri from the Gallary

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  4.  
  5.         try {
  6.  
  7.                 super.onActivityResult(requestCode, resultCode, data);
  8.  
  9.                
  10.  
  11.                         if (resultCode != RESULT_OK) {
  12.  
  13.                                 return;
  14.  
  15.                         }
  16.  
  17.                         Uri uri = data.getData();
  18.  
  19.                         Bitmap Myimage=MediaStore.Images.Media.getBitmap(mContext.getContentResolver(),uri);
  20.  
  21. }}
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


hope will help this .....

Cheers
Bins... :)
User avatar
bins1984
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Feb 08, 2008 8:20 am
Location: India

Top

Return to General

Who is online

Users browsing this forum: No registered users and 3 guests