Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android 6.0 点击拍照按钮闪退 #10

Closed
is1988 opened this issue Feb 9, 2017 · 2 comments
Closed

android 6.0 点击拍照按钮闪退 #10

is1988 opened this issue Feb 9, 2017 · 2 comments

Comments

@is1988
Copy link

is1988 commented Feb 9, 2017

02-09 15:43:25.035 4139-4139/com.stone.richeditor E/AndroidRuntime: FATAL EXCEPTION: main Process: com.stone.richeditor, PID: 4139 java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera/.Camera clip={text/uri-list U:file:///storage/emulated/0/DCIM/Camera/IMG_2017-02-09%2015%3A43%3A25.jpg} (has extras) } from ProcessRecord{40b44b1 4139:com.stone.richeditor/u0a132} (pid=4139, uid=10132) with revoked permission android.permission.CAMERA at android.os.Parcel.readException(Parcel.java:1620) at android.os.Parcel.readException(Parcel.java:1573) at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2681) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1509) at android.app.Activity.startActivityForResult(Activity.java:3978) at android.app.Activity.startActivityForResult(Activity.java:3939) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:843) at com.stone.richeditor.MainActivity.openCamera(MainActivity.java:102) at com.stone.richeditor.MainActivity$1.onClick(MainActivity.java:64) at android.view.View.performClick(View.java:5207) at android.view.View$PerformClick.run(View.java:21177) 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:5457) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)

目测权限问题

@xmuSistone
Copy link
Owner

是权限问题,自行修改吧;作者太懒,被项目弄的头大了; 体验Demo可用低版本手机

@is1988
Copy link
Author

is1988 commented Feb 9, 2017

我加上了授权的方法 不过还得特意谢谢楼主的项目很实用

// android 6.0 以上版本,监听SDK权限请求,弹出对应请求框。
if (Build.VERSION.SDK_INT >= 23) {
    RongIM.getInstance().setRequestPermissionListener(new RongIM.RequestPermissionsListener() {
        @Override
        public void onPermissionRequest(String[] permissions, final int requestCode) {
            for (final String permission : permissions) {
                if (shouldShowRequestPermissionRationale(permission)) {
                    requestPermissions(new String[] {permission}, requestCode);
                } else {
                    int isPermissionGranted = checkSelfPermission(permission);
                    if (isPermissionGranted != PackageManager.PERMISSION_GRANTED) {
                        new AlertDialog.Builder(ConversationActivity.this)
                        .setMessage("你需要在设置里打开以下权限:" + permission)
                        .setPositiveButton("确认", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                requestPermissions(new String[] {permission}, requestCode);
                            }
                        })
                        .setNegativeButton("取消", null)
                        .create().show();
                    }
                    return;
                }
            }
        }
    });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants