码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2014-07-18 16:38:51      阅读:332      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   color   os   cti   

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卡属于哪个移动运营商

标签:android   style   blog   color   os   cti   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!