首页 > 移动平台 > 详细

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

时间:2014-07-18 16:38:29      阅读:408      评论:0      收藏:0      [点我收藏+]
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");
            }
        }
    }   
}

Android 判断SIM卡属于哪个移动运营商,布布扣,bubuko.com

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

原文:http://www.cnblogs.com/123ing/p/3851032.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!