#Region Project Attributes
#ApplicationLabel: TrapPref
#VersionCode: 1
#VersionName: 1
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim prefManager As PreferenceManager
Dim prefScreen As PreferenceScreen
Dim Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Button1.Initialize("Btn1")
Button1.Text="Open Pref"
Activity.AddView(Button1,10%x,10%y,80%x,15%y)
prefScreen.Initialize("Title","Some Prefs")
CreatePrefs
End Sub
Sub Activity_Resume
LogUpdatedKeys
WriteMyActivity("Activity_Resume")
If File.Exists(File.DirDefaultExternal,"LogZ.txt") Then
ReadLogZ
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
WriteMyActivity("Activity_Pause " & UserClosed)
End Sub
Sub Btn1_Click
StartActivity(prefScreen.CreateIntent)
End Sub
Sub WriteMyActivity(Msg As String)
Dim Output As OutputStream = File.OpenOutput(File.DirDefaultExternal, "LogZ.txt", True)
Dim tw As TextWriter
tw.Initialize(Output)
Dim Sample As String
Sample=DateTime.Time(DateTime.Now) & " - " & Msg & CRLF
tw.Write(Sample)
tw.Close
End Sub
Sub CreatePrefs
Dim PC As PreferenceCategory
PC.Initialize("PC's title")
PC.AddCheckBox("T1","Title1","Summary 1",False)
PC.AddCheckBox("T2","Title2","Summary 2",False)
prefScreen.AddPreferenceCategory(PC)
End Sub
Sub LogUpdatedKeys
For Each K As String In prefManager.GetUpdatedKeys
WriteMyActivity(K & ": " & prefManager.GetBoolean(K))
Next
End Sub
Sub ReadLogZ
Dim Input As InputStream = File.OpenInput(File.DirDefaultExternal,"LogZ.txt")
Dim rw As TextReader
rw.Initialize(Input)
Dim sInput As String
sInput=rw.ReadAll
rw.Close
LogColor("File's content: " & CRLF &sInput,Colors.Gray)
End Sub