android - 当我打开手机照片时,选择一个以使用小米 MIUI 强制关闭应用程序,其他手机工作正常。谢谢你的建议?

标签 android

这是我的代码,用于在后退应用程序强制关闭且 onActivityResult() 不起作用时打开手机照片以选择一张。

Intent picture = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(picture, 1);

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        UIUtils.printLog("onActivityResult");
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case 0: // take photo
                    try {
                        mImageFile = FileUtils.createTempImageFile();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    FileUtils.cropImage(UploadIDCardActivity.this,
                            sFileUri, mImageFile, REQUEST_IMAGE_CROP);
                    break;
                case 1: // pick photo
                    try {
                        mImageFile = FileUtils.createTempImageFile();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    FileUtils.cropImage(UploadIDCardActivity.this,
                            data.getData(), mImageFile, REQUEST_IMAGE_CROP);
                    break;
                case REQUEST_IMAGE_CROP: // crop photp and upload
                    mCurrFile = mImageFile.getPath();
                    UIUtils.printLog("REQUEST_IMAGE_CROP");
                    try {
                        getDataImageUpload(mImageFile);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
            }
        }
    }

这是监视器错误,当应用强制关闭监视器时给我错误消息。错误只发生在 MIUI 上,我的手机是 xiaomi5 MIUI 8.1.6.0 Android 6.0.1

01-02 13:16:42.291 2289-2289/? E/Icon: Unable to load resource 0x00000000from pkg=com.android.systemui
                                         android.content.res.Resources$NotFoundException: Resource ID #0x0
       at android.content.res.Resources.getValue(Resources.java:1374)
       at android.content.res.MiuiResources.getValue(MiuiResources.java:145)
       at android.content.res.Resources.getDrawable(Resources.java:827)
       at android.graphics.drawable.Icon.loadDrawableInner(Icon.java:313)
       at android.graphics.drawable.Icon.loadDrawable(Icon.java:269)
       at android.graphics.drawable.Icon.loadDrawableAsUser(Icon.java:377)
       at com.android.systemui.statusbar.ExpandedIcon.getDrawable(ExpandedIcon.java:59)
       at com.android.systemui.statusbar.StatusBarIconView.getIcon(StatusBarIconView.java:174)
       at com.android.systemui.statusbar.StatusBarIconView.setIcon(StatusBarIconView.java:131)
       at com.android.systemui.statusbar.StatusBarIconView.updateDarkMode(StatusBarIconView.java:266)
       at com.android.systemui.statusbar.phone.SimpleStatusBar.updateDarkMode(SimpleStatusBar.java:233)
       at com.android.systemui.statusbar.phone.PhoneStatusBar$26.run(PhoneStatusBar.java:3169)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5458)
       at java.lang.reflect.Method.invoke(Native Method)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

最佳答案

你给权限了吗。实际上,小米设备中有权限管理器的概念,您必须请求用户权限。对于试用,您可以检查权限管理器并为您的应用程序启用必要的权限。有关详细信息,请在谷歌上阅读 xiomi 设备中的权限。

关于android - 当我打开手机照片时,选择一个以使用小米 MIUI 强制关闭应用程序,其他手机工作正常。谢谢你的建议?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41422380/

相关文章:

android - Estimote/iBeacon 不是 Android 中的 Region 类

android - 在 Android 中将自定义对象存储到内部存储的最佳方式?

android - 附加标记信息 Google Maps Api

android - 为什么youtube视频正在Android中播放时,搜索栏为什么不移动?

java - 使用 Retrofit 库的 NullPointerException - Android

java - 将 Json 值从 Android 发送到服务器并使用 SQL 将数据返回到 Android

android - java.lang.IllegalStateException : Cannot perform this operation because there is no current transaction 错误

android - GetContentHeight() 无法正常工作

java - 如何从jni将数组传递给java方法

Android Volley 库不适用于 204 和空体响应