且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

机器人 - 进入设置界面

更新时间:2023-11-19 11:03:52

根据您的需求有几个选择从应用程序弹出铃声屏幕。

Depending on your needs there are a couple of alternatives to bring up the 'Ringtones' screen from your application.

如果你想提出的实际preferences屏幕通常可通过系统设置 - 让您的用户通过应用程序修改手机的普遍铃声设置 - 您可以使用 ACTION_SOUND_SETTINGS 从常数 android.provider.Settings 类来创建一个新的意图,开始声音设置活动。

If you want to bring up the actual preferences screen that is usually available through system settings -- letting your user modify the phone's universal ringtone settings through your application -- you can use the ACTION_SOUND_SETTINGS constant from the android.provider.Settings class to create a new Intent to start the sound settings activity.

startActivityForResult(new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS, 0);

如果你想选择一个自定义铃声的应用程序中使用,你需要添加一个铃声preference preferences.xml 定义文件,像这样的:

If you want to select a custom ringtone to use in your application you need to add a RingtonePreference in your preferences.xml definition file, like this:

<RingtonePreference
  android:key="alerts_ringtone"
  android:title="Select ringtone" 
  android:showDefault="true"
  android:showSilent="true"
  android:ringtoneType=""
/>

您将能够共享preferences 使用 alerts_ringtone 的关键。

You'll be able to get the uri to the selected preference in the application's default SharedPreferences using alerts_ringtone as the key.

后一种技术使用了 preferenceActivity 班举办preference选项。我就不一一介绍了,在这里详细,因为Android的文件有良好的书面记录以及一些示例code

The latter technique uses the PreferenceActivity class to host the preference options. I won't describe that in detail here, as the Android documentation has a good writeup and some sample code.