Android Programming Press on the image to return to the main documentation page.

AHPreferenceActivity

Written by Erel Uziel / Markus Stipp

PreferenceActivity library allows you to show the standard settings interface and provides an easy way to handle applications settings.
This library requires you to modify AndroidManifest.xml. See the
tutorial for more information.

List of types:

AHPreferenceCategory
AHPreferenceManager
AHPreferenceScreen

AHPreferenceCategory

PreferenceCategory holds a group of other preferences.

Events:

None

Members:


  AddCheckBox (Key As String, Title As String, SummaryOn As String, SummaryOff As String, DefaultValue As Boolean, Dependency As String)

  AddEditText (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)

  AddIntent (Title As String, Summary As String, Intent As android.content.Intent, Dependency As String)

  AddList (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As List)

  AddList2 (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As Map)

  AddPassword (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)

  AddPreferenceCategory (PreferenceCategory As AHPreferenceCategory)

  AddPreferenceScreen (PreferenceScreen As AHPreferenceScreen, Dependency As String)

  AddRingtone (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, RingToneType As Int)

  CreateIntent As android.content.Intent

  Initialize (Title As String)

  RT_ALARM As Int

  RT_NOTIFICATION As Int

  RT_RINGTONE As Int

Members description:

AddCheckBox (Key As String, Title As String, SummaryOn As String, SummaryOff As String, DefaultValue As Boolean, Dependency As String)
Adds a preference entry with a check box. The entry values can be either True or False.
Key - The preference key associated with the value.
Title - Entry title.
SummaryOn - Entry summary (second row).
SummaryOff - Entry summary if checkbox is not checked (Set to empty string to always show SummaryOn text)
DefaultValue - The default value of this preference entry if the key does not already exist.
Dependency - A key of a preference this preference entry depends on.
AddEditText (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)
Adds a preference entry which allows the user to enter free text.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist.
Dependency - A key of a preference this preference entry depends on.
AddIntent (Title As String, Summary As String, Intent As android.content.Intent, Dependency As String)
Calls the given Intent.

This supports some types of intents. See the Example for AHPreferenceActivity. No Extra Information will be passed.
AddList (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As List)
Adds a preference entry which allows the user to choose a single item out of a list.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist. Should match one of the values.
Dependency - A key of a preference this preference entry depends on.
Values - A list of strings with the possible values.
AddList2 (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As Map)
Adds a preference entry which allows the user to choose a single item out of a list.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist. Should match one of the value keys.
Dependency - A key of a preference this preference entry depends on.
Values - A map with the possible values. The key of the map is used as the value for the preference and the value is displayed in the list.
AddPassword (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)
Adds a preference entry which allows the user to enter a password. Be aware that the password is saved uncrypted in the preferences file!
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist.
Dependency - A key of a preference this preference entry depends on.
AddPreferenceCategory (PreferenceCategory As AHPreferenceCategory)
Adds a PreferenceCategory. A preference category is made of a title and a group of entries.
Note that a PreferenceCategory cannot hold other PreferenceCategories.
AddPreferenceScreen (PreferenceScreen As AHPreferenceScreen, Dependency As String)
Adds a secondary PreferenceScreen. When the user presses on this entry the second screen will appear.

PreferenceScreen - The screen to add.
Dependency - A key of a preference this preference entry depends on.
AddRingtone (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, RingToneType As Int)
Adds a preference entry which allows the user to choose a ring tone out of a list.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist. Should match one of the value keys.
Dependency - A key of a preference this preference entry depends on.
RingToneType - Type of the Ringtone. Use RT_RINGTONE, RT_NOTIFICATION, RT_ALARM.
CreateIntent As android.content.Intent
Creates the Intent object that is required for showing the PreferencesActivity.
Example:StartActivity(PreferenceScreen1.CreateIntent)
Initialize (Title As String)
Initializes the object and sets the category title.
RT_ALARM As Int
RT_NOTIFICATION As Int
RT_RINGTONE As Int

AHPreferenceManager

Provides access to the saved settings. Using PreferenceManager you can get the stored values and modify them.

Events:

None

Members:


  ClearAll

  GetAll As Map

  GetBoolean (Key As String) As Boolean

  GetString (Key As String) As String

  GetUpdatedKeys As List

  SetBoolean (Key As String, Value As Boolean)

  SetString (Key As String, Value As String)

Members description:

ClearAll
Clears all stored entries.
GetAll As Map
Returns a Map with all the Keys and Values. Note that changes to this map will not affect the stored values.
GetBoolean (Key As String) As Boolean
Returns the Boolean value mapped to the given key. Returns False is the key is not found.
GetString (Key As String) As String
Returns the String value mapped to the given key. Returns an empty string if the key is not found.
GetUpdatedKeys As List
Returns a list with the keys that were updated since the last call to GetUpdatedKeys.
Note that the updated keys may include keys with unchanged values.
SetBoolean (Key As String, Value As Boolean)
Maps the given key to the given Boolean value.
SetString (Key As String, Value As String)
Maps the given key to the given String value.

AHPreferenceScreen


Events:

None

Members:


  AddCheckBox (Key As String, Title As String, SummaryOn As String, SummaryOff As String, DefaultValue As Boolean, Dependency As String)

  AddEditText (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)

  AddIntent (Title As String, Summary As String, Intent As android.content.Intent, Dependency As String)

  AddList (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As List)

  AddList2 (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As Map)

  AddPassword (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)

  AddPreferenceCategory (PreferenceCategory As AHPreferenceCategory)

  AddPreferenceScreen (PreferenceScreen As AHPreferenceScreen, Dependency As String)

  AddRingtone (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, RingToneType As Int)

  CreateIntent As android.content.Intent

  Initialize (Title As String, Summary As String)

  RT_ALARM As Int

  RT_NOTIFICATION As Int

  RT_RINGTONE As Int

Members description:

AddCheckBox (Key As String, Title As String, SummaryOn As String, SummaryOff As String, DefaultValue As Boolean, Dependency As String)
Adds a preference entry with a check box. The entry values can be either True or False.
Key - The preference key associated with the value.
Title - Entry title.
SummaryOn - Entry summary (second row).
SummaryOff - Entry summary if checkbox is not checked (Set to empty string to always show SummaryOn text)
DefaultValue - The default value of this preference entry if the key does not already exist.
Dependency - A key of a preference this preference entry depends on.
AddEditText (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)
Adds a preference entry which allows the user to enter free text.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist.
Dependency - A key of a preference this preference entry depends on.
AddIntent (Title As String, Summary As String, Intent As android.content.Intent, Dependency As String)
Calls the given Intent.

This supports some types of intents. See the Example for AHPreferenceActivity. No Extra Information will be passed.
AddList (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As List)
Adds a preference entry which allows the user to choose a single item out of a list.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist. Should match one of the values.
Dependency - A key of a preference this preference entry depends on.
Values - A list of strings with the possible values.
AddList2 (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, Values As Map)
Adds a preference entry which allows the user to choose a single item out of a list.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist. Should match one of the value keys.
Dependency - A key of a preference this preference entry depends on.
Values - A map with the possible values. The key of the map is used as the value for the preference and the value is displayed in the list.
AddPassword (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String)
Adds a preference entry which allows the user to enter a password. Be aware that the password is saved uncrypted in the preferences file!
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist.
Dependency - A key of a preference this preference entry depends on.
AddPreferenceCategory (PreferenceCategory As AHPreferenceCategory)
Adds a PreferenceCategory. A preference category is made of a title and a group of entries.
Note that a PreferenceCategory cannot hold other PreferenceCategories.
AddPreferenceScreen (PreferenceScreen As AHPreferenceScreen, Dependency As String)
Adds a secondary PreferenceScreen. When the user presses on this entry the second screen will appear.

PreferenceScreen - The screen to add.
Dependency - A key of a preference this preference entry depends on.
AddRingtone (Key As String, Title As String, Summary As String, DefaultValue As String, Dependency As String, RingToneType As Int)
Adds a preference entry which allows the user to choose a ring tone out of a list.
Key - The preference key associated with the value.
Title - Entry title.
Summary - Entry summary (second row).
DefaultValue - The default value of this preference entry if the key does not already exist. Should match one of the value keys.
Dependency - A key of a preference this preference entry depends on.
RingToneType - Type of the Ringtone. Use RT_RINGTONE, RT_NOTIFICATION, RT_ALARM.
CreateIntent As android.content.Intent
Creates the Intent object that is required for showing the PreferencesActivity.
Example:StartActivity(PreferenceScreen1.CreateIntent)
Initialize (Title As String, Summary As String)
Initializes the object and sets the title that will show. The summary will show for secondary PreferenceScreens.
RT_ALARM As Int
RT_NOTIFICATION As Int
RT_RINGTONE As Int

Top