当前位置:操作系统 > 安卓/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;
                 }
             }
   }
  }
 };
 

 

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,