首页 > 代码库 > Android 判断SIM卡属于哪个移动运营商
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"); } } } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。