相关疑难解决方法(0)

Android M Camera Intent +权限错误?

我正在尝试让我的应用程序为新的Android M权限更改做好准备,并发现了一些奇怪的行为.我的应用程序使用相机意图机制允许用户从相机获取图片.但是在另一个活动中需要使用具有Camera权限的摄像头本身(因为需要这个的库依赖card.io).

但是,当我尝试启动Camera意图时,只需要相机意图的活动中的M我看到以下崩溃(如果我从Manifest中删除了Camera权限,则不会发生这种情况),

> 09-25 21:57:55.260 774-8053/? I/ActivityManager: START u0
> {act=android.media.action.IMAGE_CAPTURE flg=0x3000003
> pkg=com.google.android.GoogleCamera
> cmp=com.google.android.GoogleCamera/com.android.camera.CaptureActivity
> (has clip) (has extras)} from uid 10098 on display 0 09-25
> 21:57:55.261 774-8053/? W/ActivityManager: Permission Denial: starting
> Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3000003
> pkg=com.google.android.GoogleCamera
> cmp=com.google.android.GoogleCamera/com.android.camera.CaptureActivity
> (has clip) (has extras) } from null (pid=-1, uid=10098) with revoked
> permission android.permission.CAMERA 09-25 21:57:55.263 32657-32657/?
> E/ResolverActivity: Unable to launch as uid 10098 package
> com.example.me.mycamerselectapp, while running in android:ui 09-25
> …
Run Code Online (Sandbox Code Playgroud)

android android-camera android-camera-intent android-permissions android-6.0-marshmallow

65
推荐指数
4
解决办法
5万
查看次数

撤销权限android.permission.CAMERA

我收到了错误 revoked permission android.permission.CAMERA

我在清单上使用相机权限

private void dispatchTakePictureIntent(int actionCode) {

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    switch (actionCode) {
        case ACTION_TAKE_PHOTO_B:
            File f = null;

            try {
                f = setUpPhotoFile();
                mCurrentPhotoPath = f.getAbsolutePath();
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
            } catch (IOException e) {
                e.printStackTrace();
                f = null;
                mCurrentPhotoPath = null;
            }
            break;

        default:
            break;
    } // switch

    startActivityForResult(takePictureIntent, actionCode);
}
Run Code Online (Sandbox Code Playgroud)

和错误是这样的:

E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.mobile.lunatique.photo, PID: 3590
                  java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:file:///KTP_42342.jpg} (has extras) } from …
Run Code Online (Sandbox Code Playgroud)

android

16
推荐指数
2
解决办法
3万
查看次数