Reputation: 1
I used android api for run time permission,but it didnot worked in XIAOMI MIUI。it always return 0 when i requestPermission.
Upvotes: 0
Views: 698
Reputation: 11
I found an answer.
If your application is targeting an API level before 23 (Android M) then both:ContextCompat.CheckSelfPermission and Context.checkSelfPermission doesn't work and always returns 0 (PERMISSION_GRANTED). Even if you run the application on Android 6.0 (API 23).
The solution: As I said in the 1st point, if you targeting an API level before 23 on Android 6.0 then ContextCompat.CheckSelfPermission and Context.checkSelfPermission doesn't work. Fortunately you can use PermissionChecker.checkSelfPermission to check run-time permissions.
Upvotes: 1
Reputation: 1
ok,i fixed this problem.
I used
PermissionChecker.checkPermission(this, permission, Process.myPid(),Process.myUid()
replace
ActivityCompat.checkSelfPermission(this, permission)
Upvotes: 0
Reputation: 769
I Had no problem with runtime permission on my Xiaomi MI3 with MIUI, are you sure to ask runtime permission correctly?
post you code or follow this guide: https://developer.android.com/training/permissions/requesting.html
Upvotes: 0