Home > Mobile >  Android FileProvider millet crop failure problem
Android FileProvider millet crop failure problem

Time:09-26

Albums such as topic call system, and then accept the choice of onActivityResult again call system cut out pictures, and then return to the bitmap. The other phone no problem,. Failure including on millet millet se and millet 8 system is android 9th September,
the debug to find millet in choosing pictures back road king road is not absolute, but rather FileProvider uri, so how to use this uri? Can I convert this Uri to Bitmap? If you can't give me that this Uri have what effect??

Posted on the logic code
call system album
 
Intent Intent;
If (Build) VERSION) SDK_INT & lt; 19) {
Intent=new intent (intent. ACTION_GET_CONTENT);
Intent. SetType (" image/* ");
} else {
Intent=new intent (intent. ACTION_PICK, android. The provider. The MediaStore. Images, Media, EXTERNAL_CONTENT_URI);
}
StartActivityForResult (intent, requestPic);


onActivityResult return
 
@ Override
Protected void onActivityResult (int requestCode, int the resultCode, Intent data) {
Super. OnActivityResult (requestCode, the resultCode, data);
If (requestCode==requestPic & amp; & The resultCode==Activity. RESULT_OK) {//album selection results
Photouri=data. GetData ();
StartPhotoZoom (requestPic photouri);
} else if (requestCode==requestCup & amp; & The resultCode==Activity. RESULT_OK) {//cut success
Bundle extras=data. GetExtras ();
IsNewHeadBitmap=false;
If (extras!=null) {
Photo=extras. GetParcelable (" data ");
RoundImageButtonView. SetImageBitmap (photo);
IsNewHeadBitmap=true;
}

} else if (requestCode==requestCup & amp; & The resultCode!=Activity. RESULT_OK) {//screenshot failure
IsNewHeadBitmap=false;
If (action==requestCarmela) {
if (! TextUtils. IsEmpty (bimapPath)) {
Photo=BitmapUtils. DecodeSampledBitmapFromResource (bimapPath, 320, 320);
If (photo!=null) {
RoundImageButtonView. SetImageBitmap (photo);
IsNewHeadBitmap=true;
}
}
}

}
}


cutting method
 
Public void startPhotoZoom (int code, Uri Uri) {
Action=code;
Intent Intent=new Intent (com. Android. Camera. The action. "CROP");
If (Build) VERSION) SDK_INT & gt;=Build. VERSION_CODES. N) {
Intent. AddFlags (intent. FLAG_GRANT_READ_URI_PERMISSION);//add it said temporary authorized the Uri of the target application represent file
//intent. SetFlags (intent. FLAG_GRANT_READ_URI_PERMISSION | intent. FLAG_GRANT_WRITE_URI_PERMISSION);
//uri=FileProvider. GetUriForFile (mContext BuildConfig. APPLICATION_ID + "PIC", the new File (bimapPath));//7.0
Intent. SetDataAndType (uri, "image/*");
} the else
Intent. SetDataAndType (uri, "image/*");
//set tailoring
Intent. PutExtra (" crop ", "true");
//aspectX aspectY is wide high proportion
Intent. PutExtra (" aspectX ", 1);
Intent. PutExtra (" aspectY ", 1);
//outputX outputY is cut out pictures wide high
Intent. PutExtra (" outputX ", 320);
Intent. PutExtra (" outputY ", 320);
Intent. PutExtra (" return - data ", true);
StartActivityForResult (intent, requestCup);
}


Code posted, hope bosses door see,





CodePudding user response:

The Android 7.0 future retrieval, it is not absolutely road king, need special adaptation

CodePudding user response:

reference 1/f, the wind light cloud light v10 reply:
Android 7.0 future retrieval, it is not absolutely road king, need special adaptation


Attach adaptation methods: https://blog.csdn.net/qq_19707091/article/details/78415306 (online, encounter problems know baidu, valley, dad is very important)

CodePudding user response:

reference 1/f, the wind light cloud light v10 reply:
Android 7.0 future retrieval, it is not absolutely road king, need special adaptation

Indeed, after 7.0 do the processing of the road king, but for now many phones directly to the remove or before using the API, only beautiful miui really did it

CodePudding user response:

reference yung7086 reply: 3/f
Quote: reference 1/f, the wind light cloud light v10 reply:

The Android 7.0 future retrieval, it is not absolutely road king, need special adaptation

Indeed, after 7.0 do the processing of the road king, but for now many phones directly to the remove or before using the API, the only truly beautiful miui

The custom of various mobile phone system is not

CodePudding user response:



Attach adaptation methods: https://blog.csdn.net/qq_19707091/article/details/78415306 (online, encounter problems know baidu, valley, dad is very important)


Thank you very much
Your approach is positive, is when you want to share the road king out through FileProvider to conceal the real road,, and I'm from album choose photo albums is app gave the address of a secret road king returned to me, and I want to how to use the road king. Get the picture? Equivalent to what you give is encrypted and I need. Although now use resources query to find the picture of the real, but this is not an obvious way to Google.
  • Related