简体   繁体   English

Android中双SIM卡设备的手机号码验证

[英]Mobile Number verification for dual SIM devices in Android

I have done the sim/mobile number verification (same like Whats APP) part in my app. 我已经在我的应用程序中完成了SIM /手机号验证(类似于Whats APP)部分。 something like: 就像是:

Send Message Part: 发送消息部分:

SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(mobileNumber, null, "Welcome", null, null);

Check the message received by the same/current device through BroadcastReceiver: 检查同一/当前设备通过BroadcastReceiver接收到的消息:

private  class SMSReceiver extends BroadcastReceiver{

@Override
  public void onReceive(Context context, Intent intent) {

  if(intent.getAction() != null && intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){                    
  Bundle extras = intent.getExtras();
  if (extras == null){
     _submit.setText("Register");
     _mobile_number.setError("Invalid Number");
     mProgressDialog.dismiss();
     return;
   }


    try{              
        Object[] pdus = (Object[]) extras.get("pdus");
        SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdus[0]);
        String origNumber = msg.getOriginatingAddress();
        String msgBody = msg.getMessageBody();

        String countryCode = country_codeselected ;
        String number = _mobile_number.getText().toString();
        final String mobileNumber = countryCode+number;
        final String reg_id = prefs.getString(GCM_REG_ID, ""); 

         if(PHONE_NUMBER.equals(origNumber)){
            //Success
         }

     .............................

Its working only for Single SIM devices. 它仅适用于Single SIM设备。

Can anyone help me that how to do this for dual SIM devices. 谁能帮助我,如何针对双SIM卡设备执行此操作。

Suggestions are mostly appreciable. 建议大多是可取的。

i think 我认为

https://github.com/cognalys/cogdemo will be helpful https://github.com/cognalys/cogdemo会有所帮助

Because its a new way of verifying mobile number without fee . 因为这是一种免费验证手机号码的新方法。 SMS method is a traditional method. SMS方法是一种传统方法。

private void isDualSimOrNot(){
SimNoInfo telephonyInfo = SimNoInfo.getInstance(this);

String imeiSIM1 = telephonyInfo.getImeiSIM1();
String imeiSIM2 = telephonyInfo.getImeiSIM2();

boolean isSIM1Ready = telephonyInfo.isSIM1Ready();
boolean isSIM2Ready = telephonyInfo.isSIM2Ready();

boolean isDualSIM = telephonyInfo.isDualSIM();
Log.i("Dual = "," IME1 : " + imeiSIM1 + "\n" +
        " IME2 : " + imeiSIM2 + "\n" +
        " IS DUAL SIM : " + isDualSIM + "\n" +
        " IS SIM1 READY : " + isSIM1Ready + "\n" +
        " IS SIM2 READY : " + isSIM2Ready + "\n");
}

For further implementation go through this link Android How to get Phone number from the Dual sim phone 要进一步实施,请通过此链接Android如何从Dual sim手机获取电话号码

I would avoid doing it that way since it only works on Android. 我会避免这样做,因为它仅适用于Android。 Plus, what number will you be sending it to? 另外,您将发送给哪个号码? If you send it from the SIM card, then what will you do when the SIM does not return any data? 如果从SIM卡发送,那么SIM卡不返回任何数据时该怎么办? - and If you send it to the phone number that the user entered, when they find out it came out of their own phone, you will need to add a big disclaimer about SMS charges they might incur. -并且,如果将其发送到用户输入的电话号码,则当他们发现该电话号码来自他们自己的电话时,您将需要增加关于可能产生的SMS费用的免责声明。

You can alternatively use RingCaptcha - a new service that helps you onboard verified users into your apps in seconds via SMS. 您也可以使用RingCaptcha,这是一项新服务,可帮助您通过SMS在几秒钟内将经过验证的用户加入应用程序。 Integration is a breeze with all the available plugins for web, APIs, and SDKs of all flavours. 轻松集成所有可用的Web,API和SDK插件。

[Disclaimer: I'm part of the team behind RingCaptcha] [免责声明:我是RingCaptcha背后的团队的一员]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM