Head.addeventlistener (' Tap ', function () {var image_unspecified = "image/*";//Photo album displays the file type var photozoom = 2;//Get the picture back Back key var Photolat = 1; After trimming, return key var main = plus.android.runtimeMainActivity (); h5+ Get app main activity instance object var Intent = Plus.android.importClass ("android.content.Intent"); Import Java class Intent object The following importclass are all using the Android native class var mediastore = Plus.android.importClass ("Android.provider.MediaStore"); var File = Plus.android.importClass ("Java.io.File"); var Uri = Plus.android.importClass ("Android.net.Uri"); var intent = new Intent (Intent.action_pick, NULL); Intent.setdataandtype (MediaStore.Images.Media.EXTERNAL_CONTENT_URI, image_unspecified); Intent.putextra ("scale", true); Intent.putextra ("scaleupifneeded", true); var OutPutPath = Plus.io.convertLocalFileSystemURL ("_www/head.jpg"); Main.startactivityforresult (Intent, photozoom); Main.onactivityresult = function (Requestcode, ResultCode, data) {if (Photozoom = = Requestcode) { var file = new file (OutPutPath); Output directory Uri var outputuri = uri.fromfile (file); if (data = = undefined) {return false; } plus.android.importClass (data); var uri = Data.getdata (); var cropintent = new Intent ("Com.android.camera.action.CROP"); Crop Cropintent.setdataandtype (URI, image_unspecified); After completion of the output directory Cropintent.putextra (Mediastore.extra_output, Outputuri); Cropintent.putextra ("Crop", "true"); Aspectx Aspecty is a proportional Cropintent.putextra ("Aspectx", 1) of the wide height; Cropintent.putextra ("Aspecty", 1); Outputx Outputy is a cropped picture with a wide height of Cropintent.putextra ("Outputx", 70); Cropintent.putextra ("Outputy", 70); Cropintent.putextra ("Return-data", true); Main.startactivityforresult (Cropintent, Photolat); } else if (Requestcode = = Photolat) {if (data = = undefined){return false; } var a = new File (OutPutPath); if (!a.exists ()) {Console.log (OutPutPath); Mui.toast (' clipping error '); return false; } img.src = OutPutPath; } }});
Reference article http://ask.dcloud.net.cn/question/8314
Hbuilder MUI call system crop picture, avatar crop-android