android-imageView dosent show the image on galaxy while it works on other devices -
i don't know why happening. first press "camera" button camera app starts working take picture , save it. should see picture on screen shows picture upside down disappears. work on other devices. public class cameraactivity extends activity {
private button btncamera; private imageview ivcapture; private static final int activity_start_camera_app = 0; private string mimagefilelocation = ""; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_camera); btncamera = (button)findviewbyid(r.id.btncamera); ivcapture = (imageview)findviewbyid(r.id.ivcapture); btncamera.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { takephoto(v); } }); } public void takephoto(view view){ intent callcameraapplicationintent = new intent(); callcameraapplicationintent.setaction(mediastore.action_image_capture); file photofile = null; try{ photofile = getfile(); }catch(ioexception e){ e.printstacktrace(); } startactivityforresult(callcameraapplicationintent, activity_start_camera_app); } private file getfile() throws ioexception { string timestamp = new simpledateformat("yyyymmdd_hhmmss").format(new date()); string imagefilename = "image_"+ timestamp + "_"; file storagedirectory = environment.getexternalstoragepublicdirectory(environment.directory_pictures); file image = null; image = file.createtempfile(imagefilename, ".jpg", storagedirectory); mimagefilelocation = image.getabsolutepath(); return image; } protected void onactivityresult(int requestcode,int resultcode,intent data){ if(requestcode == activity_start_camera_app && resultcode == result_ok){ ivcapture.setimagedrawable(drawable.createfrompath(mimagefilelocation));}}}
manifest
<?xml version="1.0" encoding="utf-8"?>
<uses-feature android:name="android.hardware.camera2"/> <uses-permission android:name="android.permission.write_external_storage" /> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name=".cameraactivity" android:label="@string/app_name" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application>
Comments
Post a Comment