Android App turn off without error when using camera -
there personal profile picture can choose photos , take pictures. works before, suddenly, today, tried upload photo , take pictures, app turn off without error shows:
d/i'm here 1﹕ after click camera button1 d/i'm here 2﹕ after click camera button d/i'm here take photo﹕ after click camera button w/iinputconnectionwrapper﹕ showstatusicon on inactive inputconnection
i didn't change change picture code. add other features of whole app.
i use code choose picture function
http://www.theappguruz.com/blog/android-take-photo-camera-gallery-code-sample/.
here code:
// json response node names private static string create_success = "create_success"; int request_camera = 0, select_file = 1; button btnselect; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_register); /********* change profile picture event begin **********/ btnchangeprofilepic = (button)findviewbyid(r.id.changeproilepicbtn); profilepicimageview = (imageview) findviewbyid(r.id.profilepic); btnchangeprofilepic.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { log.d("i'm here 1", "after click camera button1"); selectimage(); }//end onclick }); /********* change profile picture event end **********/ }//end oncreate private void selectimage() { final charsequence[] items = { "take photo", "choose library", "cancel" }; log.d("i'm here 2", "after click camera button"); alertdialog.builder builder = new alertdialog.builder(registeractivity.this); builder.settitle("add photo!"); builder.setitems(items, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int item) { if (items[item].equals("take photo")) { log.d("i'm here take photo", "after click camera button"); intent intent = new intent(mediastore.action_image_capture); startactivityforresult(intent, request_camera); } else if (items[item].equals("choose library")) { log.d("i'choose library", "after click camera button"); intent intent = new intent( intent.action_pick, android.provider.mediastore.images.media.external_content_uri); intent.settype("image/*"); startactivityforresult( intent.createchooser(intent, "select file"), select_file); } else if (items[item].equals("cancel")) { dialog.dismiss(); } } }); builder.show(); } @override public void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); log.d("onactivityresult", "onactivityresult"); if (resultcode == activity.result_ok) { if (requestcode == select_file) onselectfromgalleryresult(data); else if (requestcode == request_camera) oncaptureimageresult(data); } } private void oncaptureimageresult(intent data) { log.d("oncaptureimageresult", "oncaptureimageresult"); bitmap thumbnail = (bitmap) data.getextras().get("data"); bytearrayoutputstream bytes = new bytearrayoutputstream(); thumbnail.compress(bitmap.compressformat.jpeg, 90, bytes); file destination = new file(environment.getexternalstoragedirectory(), system.currenttimemillis() + ".jpg"); fileoutputstream fo; try { destination.createnewfile(); fo = new fileoutputstream(destination); fo.write(bytes.tobytearray()); fo.close(); } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } profilepicimageview.setimagebitmap(thumbnail); } @suppresswarnings("deprecation") private void onselectfromgalleryresult(intent data) { uri selectedimageuri = data.getdata(); string[] projection = { mediacolumns.data }; cursor cursor = managedquery(selectedimageuri, projection, null, null, null); int column_index = cursor.getcolumnindexorthrow(mediacolumns.data); cursor.movetofirst(); string selectedimagepath = cursor.getstring(column_index); bitmap bm; bitmapfactory.options options = new bitmapfactory.options(); options.injustdecodebounds = true; bitmapfactory.decodefile(selectedimagepath, options); final int required_size = 200; int scale = 1; while (options.outwidth / scale / 2 >= required_size && options.outheight / scale / 2 >= required_size) scale *= 2; options.insamplesize = scale; options.injustdecodebounds = false; bm = bitmapfactory.decodefile(selectedimagepath, options); profilepicimageview.setimagebitmap(bm); }
will me? thank much!
anyway, fix problem. since there no error, code , logic correct. , delete android:nohistory="true" in androidmanifest.xml file under activity.
Comments
Post a Comment