android - ImageView displays PNG but not JPEG -


strong texti trying load picture gallery , display in image view, png pictures being displayed fine jpg images not displaying @ , have no idea why

here code:

public void openga(view view){         //create ga||ery intent , set action pick object       intent galleryintent = new intent(intent.action_pick);         //set destination of intent when opens pictures         file destination = environment.getexternalstoragepublicdirectory(environment.directory_pictures);         //get path string cast uri         string path = destination.getabsolutepath();         //cast path uri         uri pathuri = uri.parse(path);         //set hte information of intetn destination , types |ook         galleryintent.setdataandtype(pathuri, "image/*");         //start activity resu|t         startactivityforresult(galleryintent, request_photo_gallery);     }  @override protected void onactivityresult(int requestcode, int resultcode, intent data) {         super.onactivityresult(requestcode, resultcode, data);          if(requestcode == request_photo_gallery && resultcode == result_ok){             //get image uri             uri imageuri = data.getdata();             try {                 //creat , input stream , send tp uri ab|e access image                 inputstream inputstream = getcontentresolver().openinputstream(imageuri);                 //decode image in input stream bitmap                 bitmap chosenimage = bitmapfactory.decodestream(inputstream);                  imageview = (imageview)findviewbyid(r.id.imageview);                 i.setimagebitmap(chosenimage);              } catch (filenotfoundexception e) {                 e.printstacktrace();             }         }     } 

this xml

 tablelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"  android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity">   <tablerow     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_weight="1">             <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="@+id/dispimage"         android:src="@drawable/phone"         android:onclick="openga"         android:layout_weight="1" /> </tablerow>  <tablerow     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_weight="1">      <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:id="@+id/imageview" /> </tablerow> </tablelayout> 

the jpg's big display in imageview. bitmapfactory unable make bitmap them lack of memory. see chosenimage becomes null.

rescale bitmap while loading.

try small .jpg see size matters.


Comments