android震動效果實現,從Settings裡面讀值

震動效果實現如下:

 

[java] if(Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) != 0) 

    Vibrator vibrator = (Vibrator) getSystemService("vibrator"); 
    vibrator.vibrate(50); 

 if(Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) != 0)
 {
  Vibrator vibrator = (Vibrator) getSystemService("vibrator");
  vibrator.vibrate(50);
 }

 

飛行模式判定:

[java] /**
* judge current airplane mode is set on
 * 
 * @return
 */ 
private boolean isAirplanemodeOn() 

    return Settings.System.getInt(getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) != 0; 

 

 

摘自 知識空間

發佈留言