android - Captured image was not set into imageview not working on samsung s3 Duos -
i simple application set image in imageview.
the image captured camera.
my code working fine in devices except samsung s3 duos android version 4.4.4
my code
package com.example.imageviewdemo; import android.net.uri; import android.os.bundle; import android.provider.mediastore; import android.app.activity; import android.content.intent; import android.content.pm.activityinfo; import android.content.res.configuration; import android.graphics.bitmap; import android.graphics.matrix; import android.view.display; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.view.windowmanager; import android.widget.imageview; public class mainactivity extends activity { imageview myimage; final int camera_capture_photo = 1; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //setrequestedorientation(activityinfo.screen_orientation_portrait); myimage=(imageview)findviewbyid(r.id.imageview1); myimage.setonclicklistener(upload); } private onclicklistener upload=new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub intent captureintent = new intent(mediastore.action_image_capture); startactivityforresult(captureintent, camera_capture_photo); } }; public void onactivityresult(int requestcode,int resultcode,intent data) { if(resultcode==result_ok) { if(requestcode==camera_capture_photo) { bundle extras = data.getextras(); bitmap photoimage = extras.getparcelable("data"); myimage.setimagebitmap(photoimage); } } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } }
androidmanifest file
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.imageviewdemo" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="18" /> <uses-permission android:name="android.permission.write_external_storage"/> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.example.imageviewdemo.mainactivity" android:label="@string/app_name" android:configchanges="orientation|keyboardhidden" android:screenorientation="portrait"> > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
my logcat shows information
06-25 16:27:04.635: i/timeline(16939): timeline: activity_idle id: android.os.binderproxy@4233b388 time:36037001 06-25 16:27:06.595: w/iinputconnectionwrapper(16939): showstatusicon on inactive inputconnection 06-25 16:27:06.705: e/openglrenderer(16939): sfeffectcache:clear(), msize = 0 06-25 16:27:15.125: w/applicationpackagemanager(16939): getcscpackageitemtext() 06-25 16:27:15.245: i/timeline(16939): timeline: activity_idle id: android.os.binderproxy@4233b388 time:36047610 06-25 16:27:15.655: w/applicationpackagemanager(16939): getcscpackageitemtext() 06-25 16:27:15.765: e/viewrootimpl(16939): senduseractionevent() mview == null 06-25 16:27:15.795: i/timeline(16939): timeline: activity_idle id: android.os.binderproxy@4233b388 time:36048161
please solve issue...
finally found solution
using recreating activity concept saved activity state , restore captured image set image view.
the code
static final string state_image = "image"; @override public void onsaveinstancestate(bundle savedinstancestate) { // save user's current state savedinstancestate.putparcelable(state_image, photoimage); // call superclass can save view hierarchy state super.onsaveinstancestate(savedinstancestate); } public void onrestoreinstancestate(bundle savedinstancestate) { // call superclass can restore view hierarchy super.onrestoreinstancestate(savedinstancestate); // restore state members saved instance photoimage=savedinstancestate.getparcelable(state_image); myimage.setimagebitmap(photoimage); }
Comments
Post a Comment