Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the reasons for the failure of photo clipping and loading in the development of Android system

Shulou Source: shulou.com Published: 2022-06-02 20:19:35 10月04日 Update

This article introduces the relevant knowledge of "what are the reasons for the failure of photo clipping and loading in the development of the Android system?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Reason 1:

Failed to get camera permission and failed to adjust the camera

If (ContextCompat.checkSelfPermission (baseActivity, Manifest.permission.CAMERA)! = PackageManager.PERMISSION_GRANTED) {/ / enter here means no permission if (ActivityCompat.shouldShowRequestPermissionRationale (baseActivity, Manifest.permission.CAMERA)) {/ / prompt has been banned / / ToastUtil.longToast (mContext, getString (R.string.you_have_cut_down_the_permission)) } else {ActivityCompat.requestPermissions (baseActivity, new String [] {Manifest.permission.CAMERA}, 100);}}

Reason two:

Android7.0 version: no adaptation

Reason 3:

In the case of all the above, when the photo is adjusted and cut after the photo is successful, the photo is not available, which shows that the loading failed.

At this time, you can check whether you have applied for storage permission in your code. This permission is easy to neglect, resulting in not getting the image all the time. In the case of camera callback, intent returns a null value again, so it is easy to get tangled here. In fact, the camera calls back some of the phone's intent values to return a null value of null, so we all get the successful pictures you took through the path.

/ / get storage permission if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {if (ActivityCompat.checkSelfPermission (baseActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)! = PackageManager.PERMISSION_GRANTED) {if (ActivityCompat.shouldShowRequestPermissionRationale (baseActivity) Manifest.permission.WRITE_EXTERNAL_STORAGE) {/ / prompt has banned} else {ActivityCompat.requestPermissions (baseActivity, PERMISSIONS_STORAGE, REQUEST_PERMISSION_CODE) }} else {Intent takePictureIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity (baseActivity.getPackageManager ())! = null) {Uri fileUri = FileProvider7.getUriForFile (baseActivity, file); takePictureIntent.putExtra (MediaStore.EXTRA_OUTPUT, fileUri) BaseActivity.startActivityForResult (takePictureIntent, TAKE_PICTURE);} else {Intent takePictureIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity (baseActivity.getPackageManager ())! = null) {Uri fileUri = FileProvider7.getUriForFile (baseActivity, file) TakePictureIntent.putExtra (MediaStore.EXTRA_OUTPUT, fileUri); baseActivity.startActivityForResult (takePictureIntent, TAKE_PICTURE);} "what are the reasons for the failure of photo cropping and loading in Android system development?" this is the end of the content, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Reasons permissions cameras photos situations systems development success content pictures more knowledge storage tips practicality learning and then code again dilemma Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia OPPO Reno Microsoft Shulou Information