Package Installer crashes in Android M after requesting permission READ_SMS

后端 未结 2 1614
梦谈多话
梦谈多话 2021-01-20 09:47

I have a Login Fragment that tries to access (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); this works well with devices up to Lo

相关标签:
2条回答
  • 2021-01-20 10:16

    You've restricted the READ_SMS manifest permission to API 22 and below.

    <uses-permission android:name="android.permission.READ_SMS" android:maxSdkVersion="22" />
    

    As I mentioned in the comments, this manifest permission is still needed in Marshmallow and above, in addition to the runtime request. Remove the maxSdkVersion attribute from the permission element.

    0 讨论(0)
  • 2021-01-20 10:17

    Declare permission in manifest like this:

    <uses-permission android:name="android.permission.READ_SMS" />
    

    Mind it, there is no maxSdkVersion attribute. Reference.

    0 讨论(0)
提交回复
热议问题