• Android 判断SIM卡属于哪个移动运营商


    package com.example.checksimoperator;
    
    import com.unity3d.player.UnityPlayer;
    
    import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.telephony.TelephonyManager;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.Toast;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            
            
            Button close = (Button)this.findViewById(R.id.button0);
            close.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    
                    checkSIM();
                }
                
            });
        }
        
        
        
        public void checkSIM(){
            TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); 
            String operator = telManager.getSimOperator(); 
            if (operator != null){
                if (operator.equals("46000") || operator.equals("46002")){
                    Toast.makeText(this, "此卡属于(中国移动)", Toast.LENGTH_SHORT).show();
                    System.out.print("此卡属于(中国移动)");
                  UnityPlayer.UnitySendMessage("Main Camera","Messgae","YD");
                    
                } else if (operator.equals("46001")){
                    Toast.makeText(this, "此卡属于(中国联通)", Toast.LENGTH_SHORT).show();  
                    System.out.print("此卡属于(中国联通)");
                    UnityPlayer.UnitySendMessage("Main Camera","Messgae","LT");
                } else if (operator.equals("46003")){
                    Toast.makeText(this, "此卡属于(中国电信)", Toast.LENGTH_SHORT).show();      
                    System.out.print("此卡属于(中国电信)");
                    UnityPlayer.UnitySendMessage("Main Camera","Messgae","DX");
                }
            }
        }   
    }
  • 相关阅读:
    LAMP环境搭建
    Httpd
    MySQL常用配置和性能压力测试:MySQL系列之十五
    MySQL的高可用实现:MySQL系列之十四
    MySQL的复制:MySQL系列之十三
    备份与恢复:MySQL系列之十二
    日志记录:MySQL系列之十一
    事务隔离实现并发控制:MySQL系列之十
    SpringMVC上传文件(图片)并保存到本地
    W10如何开启LinuxBash及安装Ubuntu
  • 原文地址:https://www.cnblogs.com/123ing/p/3851032.html
Copyright © 2020-2023  润新知