I have a Login Fragment that tries to access (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
this works well with devices up to Lo
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.
Declare permission in manifest like this:
<uses-permission android:name="android.permission.READ_SMS" />
Mind it, there is no maxSdkVersion
attribute. Reference.