检查sim卡网络服务是否可用 [英] Check if a sim card Network service is available or not

查看:240
本文介绍了检查sim卡网络服务是否可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个根据SIM卡状态更改按钮的应用程序

Hi I am developing an application that changes a button according to the SIM STATE

我为无SIM卡使用1,为SIM卡就绪使用5

I am using 1 for NO SIM and 5 for SIM READY

例如,在极少数情况下,我不提供服务,如果SIM卡是国际卡,则在其他地方无法使用.这种情况的SIM状态是什么.

In few case I have no service for example, if the SIM card is an international card , It doesn't work in other places. What is the SIM State for this type of condition.

请提出如何检查是否有SIM卡但没有服务的信息.谢谢!

Please suggest how to check when there is a SIM card but no service. Thanks!

推荐答案

请您尝试以下代码...

Hi Please can you try this code...

ref链接: https://stackoverflow.com/a/3982768/900338

TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int simState = telMgr.getSimState();
        switch (simState) {
            case TelephonyManager.SIM_STATE_ABSENT:
                // do something
                break;
            case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
                // do something
                break;
            case TelephonyManager.SIM_STATE_PIN_REQUIRED:
                // do something
                break;
            case TelephonyManager.SIM_STATE_PUK_REQUIRED:
                // do something
                break;
            case TelephonyManager.SIM_STATE_READY:
                // do something
                break;
            case TelephonyManager.SIM_STATE_UNKNOWN:
                // do something
                break;
        }

这篇关于检查sim卡网络服务是否可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆