中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

android監(jiān)控SIM卡狀態(tài)的廣播示例代碼

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
/* 
     監(jiān)聽sim狀態(tài)改變的廣播,返回sim卡的狀態(tài), 有效或者無效。 
    雙卡中只要有一張卡的狀態(tài)有效即返回狀態(tài)為有效,兩張卡都無效則返回無效。 
 */  
import android.app.Service;  
import android.content.BroadcastReceiver;  
import android.content.Context;  
import android.content.Intent;  
import android.telephony.TelephonyManager;  
  
public class SimStateReceive extends BroadcastReceiver {  
    private final static String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";  
    private final static int SIM_VALID = 0;  
    private final static int SIM_INVALID = 1;  
    private int simState = SIM_INVALID;  
      
    public int getSimState() {  
        return simState;  
    }  
  
    @Override  
    public void onReceive(Context context, Intent intent) {  
        System.out.println("sim state changed");  
        if (intent.getAction().equals(ACTION_SIM_STATE_CHANGED)) {  
            TelephonyManager tm = (TelephonyManager)context.getSystemService(Service.TELEPHONY_SERVICE);   
            int state = tm.getSimState();  
            switch (state) {  
            case TelephonyManager.SIM_STATE_READY :  
                simState = SIM_VALID;  
                break;  
            case TelephonyManager.SIM_STATE_UNKNOWN :  
            case TelephonyManager.SIM_STATE_ABSENT :  
            case TelephonyManager.SIM_STATE_PIN_REQUIRED :  
            case TelephonyManager.SIM_STATE_PUK_REQUIRED :  
            case TelephonyManager.SIM_STATE_NETWORK_LOCKED :  
            default:  
                simState = SIM_INVALID;  
                break;  
            }  
        }  
    }  
  
}  

標簽:

版權申明:本站文章部分自網(wǎng)絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:使用jq實現(xiàn)簡單的返回頂部效果

下一篇:php生成圖片縮略圖代碼類