Android Code Snippet SMS verification without permission (Android 8+)

Details - see
https://code.tutsplus.com/tutorials/android-o-phone-number-verification-with-sms-token--cms-29141

I attached relatively large sample. You can check it in emulator like described in the article.
Press button, copy token (in the log) to SMS message, send SMS.

Most of code (receiving SMS) was written by Erel.
"GetAppSpecificSmsToken"'s code is following

B4X:
Dim javaobjectInstance As JavaObject   
    javaobjectInstance.InitializeContext   
    Dim stringSMSToken As String = javaobjectInstance.RunMethod ("GetAppSpecificSmsToken", Array (Rnd (10000000, 99999999)))

#If Java
    import android.app.PendingIntent;
    import android.content.Intent;
    import android.provider.Telephony;
    import android.telephony.SmsManager;

    public String GetAppSpecificSmsToken (int intPrivateCode) {
        SmsManager mgr = SmsManager.getDefault ();
        return mgr.createAppSpecificSmsToken (buildPendingIntent (intPrivateCode));    }
    private PendingIntent buildPendingIntent (int intPrivateCode) {
        return (PendingIntent.getActivity (this, intPrivateCode, new Intent (this, main.class), 0)); }
#End If
 

Attachments

  • test.zip
    8.2 KB · Views: 481
Top