How to add own setting to system settings?

帅比萌擦擦* 提交于 2019-11-27 17:03:23

问题


I have seen applications that manage to add their own checkboxes to system settings without requiring root access.

For example, when a new TTS engine is installed, it adds its own items to the Voice input & output > Text-to-speech settings screen:

How do they do that?

If I want to add my own setting to that Text-to-speech settings screen, what hook, API and/or documentation should I be looking for?


回答1:


How do they do that?

By examining the TtsEngine sample app in the SDK, it would appear that the process is:

Step #1: Implement a TTS service. Developers who attempt to use this facility to hook arbitrary other stuff into Settings will be shot on sight.

Step #2: In the manifest entry for that service, have a <meta-data> element with android:name="android.speech.tts" and an android:resource attribute pointing to an XML resource.

Step #3: Create the aforementioned XML resource, akin to the following:

<tts-engine xmlns:android="http://schemas.android.com/apk/res/android"
  android:settingsActivity="your.settings.activity.GoesHere" />

Alas, this appears to be undocumented. Leastways, I'm not finding any references to this stuff when I search the online developer guide.



来源:https://stackoverflow.com/questions/12096555/how-to-add-own-setting-to-system-settings

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