But i found more useful info here in the forum. But now i am stuck with a problem where noware on the net is a answer to that.
I have made a level and now i want to play a alarm sound from the alarms from the android phone.
I got so far that i use the PreferenceManager in my Settings.java
Using java Syntax Highlighting
- package rabit.help.Crusoe_Tools;
- import android.content.Context;
- import android.os.Bundle;
- import android.preference.PreferenceActivity;
- import android.preference.PreferenceManager;
- public class Settings extends PreferenceActivity {
- private static final boolean ALARM = true;
- private static final String ALARMSTR = "alarm_togle";
- private static final int VALUE = 2;
- private static final String VALUESTR = "list";
- private static final String SOUND = "";
- private static final String SoundSTR = "tone_select";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.settings);
- }
- public static boolean getAlarmState(Context context) {
- return PreferenceManager.getDefaultSharedPreferences(context)
- .getBoolean(ALARMSTR, ALARM);
- }
- public static int getAlarmValue(Context context) {
- return PreferenceManager.getDefaultSharedPreferences(context)
- .getInt(VALUESTR, VALUE);
- }
- public static String getAlarmSound(Context context) {
- return PreferenceManager.getDefaultSharedPreferences(context)
- .getString(SoundSTR, SOUND);
- }
- }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
and the xml file looks like this:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <PreferenceCategory android:title="Level Settings"
- android:key="level_settings">
- <RingtonePreference android:title="Alarm Sound"
- android:showSilent="false" android:key="tone_select"
- android:showDefault="false" android:ringtoneType="notification"></RingtonePreference>
- <CheckBoxPreference android:key="alarm_togle"
- android:title="Alarm On/Off"></CheckBoxPreference>
- <ListPreference android:key="list" android:title="Set Trigger Value"
- android:entries="@array/sense_lable" android:entryValues="@array/sense_value"></ListPreference>
- </PreferenceCategory>
- </PreferenceScreen>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
but how do i now play the sound on a certain event in main activity ?
I tried it with the RingTone class but i cant figure it out ????
I hope some one can help : )
Best regards Anubis

