koa73 koa73 - 8 days ago 4
Android Question

XIAOMI MI4W with android 6.0.1 not set SMS_READ permission by programmatically

I'm setting up permission in Manifest file

<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS" />

But unfortunatly I can't get SMS permissin, after I setted up application, I should go to security property of smartphone and set it by myself. What the reason, is it reason of MI restrictions or I must set somthing else in 6 version of Android. This worked on previos version on this smartphone.


From Android marshmallow you need to give run time permission. Add below given code in your launch activity onCreate() method.

String permission = Manifest.permission.READ_SMS;
if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED){

    if (!ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)){
        requestPermissions(new String[]{permission}), SMS_PERMISSION);