Changing vibrate setting

安稳与你 提交于 2019-12-24 16:12:43

问题


Ok so I'm very new to android. My gf asked me to make a very simple app for her so she could easily switch from always vibrate to never vibrate. Seemed like a simple enough task. So I've got a toggle button, and it changes the setting, but I keep running into one big issue. It won't change between always and never. if I set it to always it will swap between always and only in silent mode, or if I set it to never it switches between only not in silent mode and never. did I miss some obvious but mudane detail? this is my swap code.

public void onClick(View arg0) {

            if (vibrateOn) {
                vibrateOn = false;
                adManag.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
                adManag.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);
            } else {
                vibrateOn = true;
                adManag.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
                adManag.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ON);
            }

            Log.d(TAG, "after " + Integer.toString(adManag.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER)));
        }

来源:https://stackoverflow.com/questions/11264550/changing-vibrate-setting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!