如何以编程方式检查,获取和设置Android手机中的触摸设置?

时间:2014-03-21 11:43:09

标签: android touch

是否可以通过编程方式获取Android中的各种触摸设置,例如:

- >拨号盘触摸音

- >触摸声音

- >屏幕锁定声音

- >触摸时振动

我尝试访问System.Settings中的各种常量,但我没有提到触摸设置的常量。任何人都可以向我提供有关我可以使用的API或常量的信息吗?

3 个答案:

答案 0 :(得分:10)

使用以下方法检查

<强> - &GT;拨号盘触摸音:

boolean isDtmfToneEnabled = Settings.System.getInt(contentResolver,
        Settings.System.DTMF_TONE_WHEN_DIALING, 1) != 0;

<强> - &GT;触摸声音:

boolean isTouchSoundsEnabled = Settings.System.getInt(contentResolver,
        Settings.System.SOUND_EFFECTS_ENABLED, 1) != 0;

<强> - &GT;屏幕锁定声音:

boolean islockScreenSoundsEnabled = Settings.System.getInt(contentResolver,
        "lockscreen_sounds_enabled", 1) != 0;

<强> - &GT;触摸时振动:

boolean isVibrateOnTouchEnabled = Settings.System.getInt(contentResolver,
        Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) != 0;

您可以使用putInt() API更改其值。 希望这会有所帮助。

答案 1 :(得分:0)

禁用振动触摸:

boolean isVibrateOnTouchEnabled = Settings.System.getInt(getContentResolver(),
                            Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) != 0;
if(isVibrateOnTouchEnabled) {
Settings.System.putInt(getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 0);
Toast.makeText(MainActivity.this, "Vibration touch Off", Toast.LENGTH_SHORT).show();
}

答案 2 :(得分:0)

禁用屏幕锁定声音

boolean islockScreenSoundsEnabled = Settings.System.getInt(getContentResolver(),
                            "lockscreen_sounds_enabled", 1) != 0;
                  if(islockScreenSoundsEnabled) {
                      Settings.System.putInt(getContentResolver(),"lockscreen_sounds_enabled", 0);
                  }