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

小米9检查Manifest.permission.NFC权限报错 #6

Open
linq8261 opened this issue Nov 28, 2019 · 5 comments
Open

小米9检查Manifest.permission.NFC权限报错 #6

linq8261 opened this issue Nov 28, 2019 · 5 comments

Comments

@linq8261
Copy link

int checkOp = appOpsManager.checkOp(AppOpsManager.permissionToOp(permission), Process.myUid(), context.getPackageName());

permission为android.permission.NFC的时候AppOpsManager.permissionToOp(permission)返回null,然后checkOp就抛空指针异常了

@MichaelJokAr
Copy link
Owner

可以去掉这个检查了,前几年厂商喜欢自己加东西。最近小米改的跟android原生差不多一样了

@linq8261
Copy link
Author

可以去掉这个检查了,前几年厂商喜欢自己加东西。最近小米改的跟android原生差不多一样了

就是因为小米跟原生不一样才百度的才看到你这个的。

@linq8261
Copy link
Author

我现在问题是小米9(其它版本没试),我需要NFC,NFC的是普通权限,其它手机直接写在manifest里面就行了,但是小米它应用权限管理那里有个NFC,无论你选“允许”、“询问”还是“拒绝”,在调用ActivityCompat.checkSelfPermission的时候都返回PERMISSION_GRANTED,重点是只有选了“允许”才能正常使用NFC,我又没办法判断当前是选了什么,,,

@linq8261
Copy link
Author

linq8261 commented Dec 5, 2019

已经解决了,写成博客了,有需要的可以参考下。
https://blog.csdn.net/qiantujava/article/details/103275979

@MichaelJokAr
Copy link
Owner

厉害,这条不关了,给有需要的同学查看

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