Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report