in android app basic functions work fine, but the "Automate reading the SMS pin" function noted in the document is not working.
Asked
Active
Viewed 249 times
-6
-
`function noted in the document below is not working` -- which function ? – ρяσѕρєя K Dec 15 '16 at 05:47
-
Automate reading the SMS – Vishnu V S Dec 15 '16 at 05:52
-
Unclear what you are asking :) – ρяσѕρєя K Dec 15 '16 at 05:53
-
in their document they provided a feature for reading sms pin automatically by adding a permission for reading sms in manifest that is not working – Vishnu V S Dec 15 '16 at 05:57
2 Answers
2
First, add SMS permission in your manifest file.
<uses-permission android:name="android.permission.RECEIVE_SMS" />
Then, declare the runtime permission at the time of Login or Use my phone number activity. Add this method to your LoginActivity.class.
public static class UtilitiesPhone {
public static final int MY_PERMISSIONS_REQUEST_READ_PHONE_STATE = 130;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static boolean checkPermission(final Context context) {
int currentAPIVersion = Build.VERSION.SDK_INT;
if(currentAPIVersion>=android.os.Build.VERSION_CODES.M) {
int permissionPHONE = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE);
int permissionSMS = ContextCompat.checkSelfPermission(context, Manifest.permission.SEND_SMS);
List<String> listPermissionsNeeded = new ArrayList<>();
if (permissionPHONE != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.READ_PHONE_STATE);
}
if (permissionSMS != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(Manifest.permission.SEND_SMS);
}
if (!listPermissionsNeeded.isEmpty()) {
ActivityCompat.requestPermissions((Activity) context,
listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), MY_PERMISSIONS_REQUEST_READ_PHONE_STATE);
return false;
}
}else{
return true;
}
return true;
}
}
declare this in your onCreate
final boolean result= LoginActivity.UtilitiesPhone.checkPermission(this);
And done. Now the autofill works like charm.
Note that you can choose to keep the phone state permission or just remove it.

Pang
- 9,564
- 146
- 81
- 122

Shubhendra
- 117
- 1
- 13
-
Thank you for the answer, but your code checks for READ_PHONE_STATE and SEND_SMS permissions and Digits needs only RECEIVE_SMS permission... – Ilya Jun 11 '17 at 10:02
0
As per Document, you need to add RECEIVE_SMS
permission to enable Automate Reading the SMS Pin.
Adding the permission below, in the
AndroidManifest.xml
, allows Digits to read the SMS pin therefore making the login process easier.
<uses-permission android:name="android.permission.RECEIVE_SMS"/>

Priyank Patel
- 12,244
- 8
- 65
- 85