2016-02-25 73 views
0

我必须在我的android手机上找到双SIM卡号码。我检查了很多网站,我发现我必须使用getdeviceid(0) or getdeviceid(1)但它不工作。它示出了错误如何在Android中获得双SIM卡IMEI号码

该代码是

TelephonyManager telephonyManager = 
        (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); 

      String imei = telephonyManager.getDeviceId(0); 
      String imei1 = telephonyManager.getDeviceId(1); 

我已附加的屏幕截图。请检查并回复我

enter image description here

回答

0
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE); 
String m1PhoneNumber = tMgr.getLine1Number(); 
String m2PhoneNumber = tMgr.getLine2Number(); 


<uses-permission android:name="android.permission.READ_PHONE_STATE"/> 
+0

你好,这是电话号码的工作。我想imei号码 –

0

其仅在API等级22以上

if (android.os.Build.VERSION.SDK_INT >= 22) { 
      try { 
       TelephonyManager telephonyManager = (TelephonyManager) 
         getSystemService(Context.TELEPHONY_SERVICE); 
       SubscriptionManager subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE); 
       int Count = subscriptionManager.getActiveSubscriptionInfoCount(); 
       if (telephonyManager != null) { 

        if (Count > 1) { 
         if (android.os.Build.VERSION.SDK_INT >= 22) { 
          SIM1 = telephonyManager.getDeviceId(0); 
          SIM2 = telephonyManager.getDeviceId(1); 

          if (!SIM1.equalsIgnoreCase("") && !SIM2.equalsIgnoreCase("")) { 
           isDualSIM = true; 
          } 

         } 
        }else{ 
         // single sim 
        } 
       } 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
+0

仍然没有工作,有相同的错误...他们是在SubscriptionManager新错误...请帮助 –

相关问题