i use google photo app pick gallery photo , when crop picture , save,it catch exception,here code :
goto_picture.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { intent = new intent(intent.action_pick, null); intent.setdataandtype( mediastore.images.media.external_content_uri, image_unspecified); startactivityforresult(intent, photo_zoom); dialog.cancel(); } }); @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (resultcode == activity.result_ok) { if (requestcode == photo_graph) { startphotozoom(uri.fromfile(file)); string imagepath = systemutils.getsdpath() + "/temp.jpg"; file picture = new file(imagepath); if (picture.exists()) { picturebitmap = bitmapfactory.decodefile(imagepath); imageutils.savecachebitmap(picturebitmap); rveditavatar.setimagebitmap(picturebitmap); } } if (requestcode == photo_zoom) { startphotozoom(data.getdata()); } if (requestcode == photo_result) { bundle extras = data.getextras(); if (extras != null) { picturebitmap = extras.getparcelable("data"); bytearrayoutputstream stream = new bytearrayoutputstream(); picturebitmap.compress(bitmap.compressformat.jpeg, 100, stream); imageutils.savecachebitmap(picturebitmap); rveditavatar.setimagebitmap(picturebitmap); } } } } public void startphotozoom(uri uri) { intent intent = new intent("com.android.camera.action.crop"); intent.setdataandtype(uri, "image/*"); intent.putextra("crop", "true"); intent.putextra("aspectx", 1); intent.putextra("aspecty", 1); intent.putextra("outputx", 180); intent.putextra("outputy", 180); intent.putextra("return-data", true); intent.putextra("outputformat", bitmap.compressformat.jpeg.tostring()); startactivityforresult(intent, photo_result); } the logcat: process: com.google.android.apps.photos, pid: 7031 java.lang.runtimeexception: unable resume activity {com.google.android.apps.photos/com.google.android.apps.photos.photoeditor.intents.editactivity}: java.lang.unsupportedoperationexception: no 'output' specified , can not save specified inputuri: content://com.google.android.apps.photos.contentprovider/0/1/content%3a%2f%2fmedia%2fexternal%2fimages%2fmedia%2f72072/actual
as exception said, have specify output following code.
intent.putextra(mediastore.extra_output, someoutputpath); and return data not secure in case of big image cropped may cause crash. think that's why forces use output not data directly. may set return-data false well:
intent.putextra("return-data", false);
Comments
Post a Comment