froyo 中的振动设置

发布于 2024-09-25 12:25:13 字数 968 浏览 0 评论 0原文

我在 froyo 中读到,如果您使用 setVibrateSettings() 更改振动设置,它不会与 SO 振动设置同步。然后我发现人们将此解决方法与此链接中的某些功能一起使用:

https://android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/src/com/android/settings/SoundSettings.java

但是,该源代码有两个调用:

 173        boolean vibeInSilent = (Settings.System.getInt(
 174             getContentResolver(),
 175             Settings.System.VIBRATE_IN_SILENT,
 176             1) == 1);

 227        Settings.System.putInt(getContentResolver(),
 228             Settings.System.VIBRATE_IN_SILENT,
 229             vibeInSilent ? 1 : 0);

这是与我尝试在代码中更改振动设置的唯一区别。但是 Settings.System.VIBRATE_IN_SILENT 似乎在 2.2 中被删除,所以当我更改振动设置“正常,关闭,仅在静音”时,然后我转到 SO 音频设置,并且 vib 值不同,并且如果我返回我的应用程序,vib 设置也与我之前选择的不同。有什么想法吗?

I read that in froyo if you change vibrate settings with setVibrateSettings() it doesn't sync with SO vibrate settings. Then I found this workaround that people use with some of the functions in this link:

https://android.googlesource.com/platform/packages/apps/Settings/+/froyo-release/src/com/android/settings/SoundSettings.java

However, that source code there are two calls to:

 173        boolean vibeInSilent = (Settings.System.getInt(
 174             getContentResolver(),
 175             Settings.System.VIBRATE_IN_SILENT,
 176             1) == 1);

 227        Settings.System.putInt(getContentResolver(),
 228             Settings.System.VIBRATE_IN_SILENT,
 229             vibeInSilent ? 1 : 0);

That are the only difference with what I try to do in my code to change vibrate setttings. But Settings.System.VIBRATE_IN_SILENT seems to be removed in 2.2, so when I change vibrate settings "normal, off, only in silent", then I go to SO audio settings and vib value is different, and if i go back to my app, vib settings are also different to what i selected before. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2024-10-02 12:25:13

尝试以下链接:
http://www .kiwidoc.com/java/l/p/android/android/8/p/android.provider/c/Settings.System

根据我的尝试,该设置仍然存在,但没有像以前那样公开。仍然可以使用 Settings.System.putInt(...) 进行设置,只需指定名称“vibrate_in_silent”。

我想有一天这将不再起作用,所以我建议以任何可能的方式保护您的代码(首先通过调用 getInt 检查设置是否存在,添加 try-catch...)

Try the following link:
http://www.kiwidoc.com/java/l/p/android/android/8/p/android.provider/c/Settings.System

From what I have tried, the setting still exist but not exposed as it used to be. It can still be set using the Settings.System.putInt(...) just specify the name "vibrate_in_silent".

I guess that someday this will no longer work so I recommend protecting your code in any way possible (check if setting exist by calling getInt first, add try-catch...)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文