Gallery intent tutorial
Our goal is to start the users gallery application, allow him to select an image, and use the chosen image in our application.
API Level 3 required!
We will start the operation on a buttons onclick event, implemented as follows:
- private static Bitmap rotateImage = null;
- private ImageView imageView;
- private static final int GALLERY = 1;
In order to avoid out of memory errors, we must recycle the previous image when the user presses the button second times or after that, so the returned bitmap is stored as a member variable, so we still have a reference for it when it is needs to be recycled.


We process the result in the onActivityResult method, which is called automatically when the gallery is finished.
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == GALLERY && resultCode != 0) {
- Uri mImageUri = data.getData();
- try {
- if (getOrientation(getApplicationContext(), mImageUri) != 0) {
- Matrix matrix = new Matrix();
- matrix.postRotate(getOrientation(getApplicationContext(), mImageUri));
- if (rotateImage != null)
- rotateImage.recycle();
- imageView.setImageBitmap(rotateImage);
- } else
- e.printStackTrace();
- e.printStackTrace();
- }
- }
- }
The getOrientation method, used above returns the angle the image was taken. So if it was made with a rotated phone we must rotate the image before we can correctly display it in an ImageView. It can me implemented with the help of the Android MediaStore.

Download code: LINK
New tutorials from Helloandroid
Recent Apps
Android on Twitter
-
@KellyG41791 (Kelly Greatrex)
I've just received an achievement: Saver http://t.co/zFzNteNg #Android #Androidgames #Gameinsight
13 min 32 sec ago -
@corey_latislaw (Corey Leigh Latislaw)RT @androidphilly: Want to get started with #Android development? Join us this Wednesday for a beginner class: http://t.co/bdUJZiju
13 min 35 sec ago -
@androidphilly (Android Alliance)Want to get started with #Android development? Join us this Wednesday for a beginner class: http://t.co/bdUJZiju
13 min 40 sec ago -
@XxDiatabssxX (mark hughes)Hurray! I've completed a "Holiday decorations" task! 39 http://t.co/JrBGWxX0 #android #gameinsight #androidgames
13 min 41 sec ago -
13 min 41 sec ago
Poll
Useful resources
Android Development Projects
- Private project for Petterpp1 [WRD] by geomaster909
- Modifications on an Android Game by tymex
- app dev for techcity by dany2g
- Android App by dvlinh
- Iphone app by nabzyd
- Betfair Mobile App by Daaniel
- Need App Developer/Designer for iPhone, iPad by lplco
- Android Maps - Saving GeoLocations to MySql database. by adelshehri
- Prototype Android Apps display Information from database by getitonline
- Metal Weigh Calculator by mpmakwana



Comments
Great ArticlE >> ThX AloT
Great ArticlE >> ThX AloT ..
I ReallY EnjoyeD ReadinG it
It is very useful .. and u have great style
I hope u can visit my site below
And .. I,m Waiting for more
شات مصرى ,
شات مصرى ,
شات مصرى ,
شات مصرية ,
شات مصريه ,
دردشة مصرية ,
دردشة بنت مصرية ,
شات بنت مصرية ,
شات بنت مصر ,
دردشة بنت مصر ,
شات ,
دردشه مصريه ,
شات بنات مصر ,
دردشة بنات مصر ,
شات مصرى بنات ,
شات مصر ,
دردشة ,
شات اسكندرية ,
شات القاهرة ,
شات المنصورة ,
شات طنطا ,
شات السويس ,
شات الشرقية ,
شات المنوفية ,
شات الفيوم ,
شات بنى سويف ,
شات سوهاج ,
شات الصعيد ,
شات الزقازيق ,
شات جامعة القاهرة ,
شات جامعة اسكندرية ,
شات بنت السعودية ,
شات بنت البحرين ,
شات بنت الكويت ,
شات بنت فلسطين ,
شات بنت المغرب ,
شات بنت الامارات ,
شات بنت اليمن ,
شات بنت العراق ,
شات مصراوى ,
شات بنات ,
روتانا سينما ,
روتانا سينما مشاهدة مباشرة ,
روتانا سينما بث مباشر ,
روتانا سينما اونلاين ,
I hope u can find something useful About it .. Enjoy
Thanks .. lol i had to read it twice
شات صوتي | دردشة صوتية | كلام
شات صوتي
| دردشة صوتية
|
كلام
| شات كلام
|
دردشة كلام
| دردشة صوتية
|
شات صوتي
| شات
|
Chat Voice
| ahj w,jd
شات صوتي
| دردشة صوتية
|
شات صوتي
| دردشة صوتية
|
دردشه
| دردشة
|
صوتي
| صوتية
|
شات صوتي
| دردشة صوتية
|
شات صوتي
| دردشة صوتية
|
الكلام
| دردشه صوتيه
|
]v]am w,jdm
| ]v]ai w,jdi
شات صوتي
شات صوتي
شات صوتي