android 判斷是否有sim卡及運營商


個人網站http://www.ravedonut.com/ 

判斷是否有sim卡的方法:

int absent = TelephonyManager.SIM_STATE_ABSENT;    
        if (1 == absent)   
        {  
         Log.d(TAG,"請確認sim卡是否插入或者sim卡暫時不可用!");  
        }  
        


判斷是哪個運營商的

  TelephonyManager telManager = (TelephonyManager) getSystemService(Activity.TELEPHONY_SERVICE);   
        String operator = telManager.getSimOperator();   
        Log.d(TAG,"operator:"+operator);
        if(operator!=null)
        {   
         if(operator.equals("46000") || operator.equals("46002"))
         {   
          Log.d(TAG,"中國移動");
         }else if(operator.equals("46001")){   
          Log.d(TAG,"中國聯通");
         }else if(operator.equals("46003")){   
          Log.d(TAG,"中國電信");
         }   
        }   

 


  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM