bitmap - Android app crashes after i take a picture -
my app starts in frontpageactivity, , has button allows me go photographic camera take picture. 1 time image taken, app should direct me front end page , show me picture. 1 time i've taken picture, app crashes. can't emulator take image i'm doing on phone, i'm not getting error messages besides app has stopped. code;
public class cameraactivity extends activity { private static final int camera_request = 1888; public imageview imageview; public static final string uri_path = "uri"; uri imageuri = null; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_frontpage); this.imageview = (imageview) this.findviewbyid(r.id.pictureimageview); intent cameraintent = new intent( android.provider.mediastore.action_image_capture); startactivityforresult(cameraintent, camera_request); } protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == camera_request && resultcode == result_ok) { bitmap photo = (bitmap) data.getextras().get("data"); imageview.setimagebitmap(photo); intent frontpageintent = new intent(this, frontpageactivity.class); imageuri = data.getdata(); frontpageintent.putextra(uri_path, imageuri.tostring()); frontpageintent.putextra("mapphoto", photo); startactivity(frontpageintent); } } } and
public class frontpageactivity extends activity { private static final string number = "number"; private static final string my_pref = "mypref"; private static final string na = "na"; private imageview imageview; private string enteredphonenumber; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_frontpage); bitmap bitmap = getintent().getparcelableextra("mapphoto"); if (bitmap != null) { imageview.setimagebitmap(bitmap); } getenteredphonenumber(); button callbutton = (button) findviewbyid(r.id.callbutton); this.imageview = (imageview) this.findviewbyid(r.id.pictureimageview); callbutton.setonclicklistener(makephonecall); } public void gotocamera(view v) { intent intent = new intent(this, cameraactivity.class); startactivity(intent); } private void getenteredphonenumber() { sharedpreferences sharedpref = getsharedpreferences(my_pref, mode_private); enteredphonenumber = sharedpref.getstring(number, na); } private onclicklistener makephonecall = new onclicklistener() { @override public void onclick(view v) { intent callintent = new intent(intent.action_call); callintent.setdata(uri.parse("tel:18181818," + enteredphonenumber)); startactivity(callintent); } }; } logcat info:
10-29 08:15:19.530: e/androidruntime(907): fatal exception: main 10-29 08:15:19.530: e/androidruntime(907): process: com.netdesign1813, pid: 907 10-29 08:15:19.530: e/androidruntime(907): java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=1888, result=-1, data=intent { act=inline-data (has extras) }} activity {com.netdesign1813/com.netdesign1813.cameraactivity}: java.lang.nullpointerexception 10-29 08:15:19.530: e/androidruntime(907): @ android.app.activitythread.deliverresults(activitythread.java:3365) 10-29 08:15:19.530: e/androidruntime(907): @ ndroid.app.activitythread.handlesendresult(activitythread.java:3408) 10-29 08:15:19.530: e/androidruntime(907): @ android.app.activitythread.access$1300(activitythread.java:135) 10-29 08:15:19.530: e/androidruntime(907): @ android.app.activitythread$h.handlemessage(activitythread.java:1244) 10-29 08:15:19.530: e/androidruntime(907): @ android.os.handler.dispatchmessage(handler.java:102) 10-29 08:15:19.530: e/androidruntime(907): @ android.os.looper.loop(looper.java:136) 10-29 08:15:19.530: e/androidruntime(907): @ android.app.activitythread.main(activitythread.java:5017) 10-29 08:15:19.530: e/androidruntime(907): @ java.lang.reflect.method.invokenative(native method) 10-29 08:15:19.530: e/androidruntime(907): @ java.lang.reflect.method.invoke(method.java:515) 10-29 08:15:19.530: e/androidruntime(907): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) 10-29 08:15:19.530: e/androidruntime(907): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) 10-29 08:15:19.530: e/androidruntime(907): @ dalvik.system.nativestart.main(native method) 10-29 08:15:19.530: e/androidruntime(907): caused by: java.lang.nullpointerexception 10-29 08:15:19.530: e/androidruntime(907): @ com.netdesign1813.cameraactivity.onactivityresult(cameraactivity.java:36) 10-29 08:15:19.530: e/androidruntime(907): @ android.app.activity.dispatchactivityresult(activity.java:5423) 10-29 08:15:19.530: e/androidruntime(907): @ android.app.activitythread.deliverresults(activitythread.java:3361) 10-29 08:15:19.530: e/androidruntime(907): ... 11 more i hope can spot error, because can't.
it might problem image size taken camera. if image size more cannot image activity in intent.
once seek limit size of image next while making photographic camera request.
intent cameraintent = new intent(android.provider.mediastore.action_image_capture); cameraintent.putextra( android.provider.mediastore.extra_size_limit, "720000"); startactivityforresult(cameraintent, camera_request_idphoto); android bitmap camera imageview
No comments:
Post a Comment