Tag: greater than or equal to Rect causes ERR ash strong implementation article allows
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Under normal circumstances, call the system camera to take pictures:
If you click on the "OK" icon after taking the photo, the Returned resultcode =-1 (ACTIVITY.RESULT_OK);
If you click on the "Back" button at the bottom, the returned resultcode = 0 (activity.result_canceled).
Simple to invoke the system camera's notation:
// Call system to take pictures New New Date () + ". jpg"= environment.getexternalstoragedirectory () + File.separator + "tempwhy" + File.separator + photofilename; // You must use a folder that already exists tempwhyIntent.putextra (Mediastore.extra_output, Uri.fromfile (new File (Imgurl)) ); // start the photo-taking form. and register callback processing Startactivityforresult (intent, 1111);
Processing on return
@Override public void onactivityresult (int ResultCode, Intent data) { super .onactivityresult (Requestcode, ResultCode, data); if (resultcode == ACTIVITY.RESULT_OK) { /span>switch (Requestcode) { // camera feature case 1111: break ; } }}
So, the call system that came up today on the Android6.0 model, the value of the ResultCode returned by the camera is always equal to 0, mainly due to the following two causes:
One, do not implement run-time permissions processing
When the android:targetsdkversion value in the Androidmanifest.xml file is greater than or equal to 23, the run-time permission must be processed, because the permission to read and write to the SD card Android.permission.WRITE_SETTINGS belongs to run-time permissions.
Solution:
Scenario One: Modify the Android:targetsdkversion value in the Androidmanifest.xml file to less than 23
Scenario two: Adding processing of run-time permissions
second, the Storage Directory (folder) is not created when you save the path to the designated picture
Solution:
Create a storage directory before calling the system camera to take a photo
Android6.0 model on call system camera take photos return ResultCode value always equals 0 problem