当前位置:操作系统 > 安卓/Android >>

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; 

 

 

摘自 知识空间

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