Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android 判斷飛行模式的狀態

Android 判斷飛行模式的狀態

編輯:關於Android編程

正文

 

[java]
private BroadcastReceiver br = new BroadcastReceiver() { 
     
    @Override 
    public void onReceive(Context context, Intent intent) { 
        String action = intent.getAction(); 
        if(action.equals("com.android.FMRadio.FlightClock")){ 
            //獲取到飛行模式狀態 ,true開啟,false關閉  
            int isAirplaneMode = Settings.System.getInt(mContext.getContentResolver(),   
                    Settings.System.AIRPLANE_MODE_ON, 0) ; 
            boolean find = (isAirplaneMode == 1)?true:false; 
            if(find){ 
                Toast.makeText(mContext, R.string.toast_in_flight, Toast.LENGTH_SHORT).show(); 
                if (mIsPlaying) { 
                    refreshImageButton(false); 
                    refreshActionMenuItem(false); 
                    refreshPopupMenuItem(false); 
                    refreshActionMenuPower(false); 
                    exitService(); 
          return; 
                } 
            } 
        } 
    } 
}; 

 private BroadcastReceiver br = new BroadcastReceiver() {
  
  @Override
  public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if(action.equals("com.android.FMRadio.FlightClock")){
    //獲取到飛行模式狀態 ,true開啟,false關閉
    int isAirplaneMode = Settings.System.getInt(mContext.getContentResolver(), 
                     Settings.System.AIRPLANE_MODE_ON, 0) ;
             boolean find = (isAirplaneMode == 1)?true:false;
             if(find){
              Toast.makeText(mContext, R.string.toast_in_flight, Toast.LENGTH_SHORT).show();
              if (mIsPlaying) {
                     refreshImageButton(false);
                     refreshActionMenuItem(false);
                     refreshPopupMenuItem(false);
                     refreshActionMenuPower(false);
                     exitService();
     return;
                 }
             }
   }
  }
 };
 

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved