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

Discussion in 'Code Snippets' started by Semen Matusovskiy, Sep 13, 2018.

  1. Semen Matusovskiy

    Semen Matusovskiy Active Member Licensed User

    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

    Code:
    Dim javaobjectInstance As JavaObject   
        javaobjectInstance.InitializeContext   
        
    Dim stringSMSToken As String = javaobjectInstance.RunMethod ("GetAppSpecificSmsToken"Array (Rnd (1000000099999999)))

    #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
     

    Attached Files:

  2. PassionDEV

    PassionDEV Active Member Licensed User

    can this method work on android phones below 8 ?
     
  3. Semen Matusovskiy

    Semen Matusovskiy Active Member Licensed User

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice