Preference activity not working?

Penfound

Active Member
Licensed User
Longtime User
Hi everyone,

I tried following the tutorial and example for using the Preference activity and added the line to the manifest but everytime I click on the menuitem I get this error.

I kept the code as it was in the example with the various subs so I can only assume that there is something I should have done as the error mentions the package name.

java.io.FilenotfoundException intent { cmp=com.penfound.bmbdroid/anywheresoftware.b4a.objects (has extras)} .bal

I changed the word settings to preferences as that is the name of my layout for the task and commented out hte creation of a button....

Sub Process_Globals
Dim manager As PreferenceManager
Dim screen As PreferenceScreen
End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
CreatePreferenceScreen
If manager.GetAll.Size = 0 Then SetDefaults
End If
' Dim btn As Button
' btn.Initialize("btn")
' btn.Text = "Settings"
' Activity.AddView(btn, 10dip, 10dip, 200dip, 100dip)
End Sub

Sub CreatePreferenceScreen
ClearAll
screen.Initialize("Preferences","")
'create two categories
Dim cat1, cat2 As PreferenceCategory
cat1.Initialize("Category 1")
cat1.AddCheckBox("check1", "Checkbox1", "This is Checkbox1", True)
cat1.AddCheckBox("check2", "Checkbox2", "This is Checkbox2", False)
cat1.AddEditText("edit1", "EditText1", "This is EditText1", "")

cat2.Initialize("Category 2")
cat2.AddList("list1", "List1", "This is List1", "", Array As String("Black", "Red", "Green", "Blue"))

'add the categories to the main screen
screen.AddPreferenceCategory(cat1)
screen.AddPreferenceCategory(cat2)
End Sub

Sub HandleSettings
Select manager.GetString("list1")
Case "Black"
Activity.Color = Colors.Black
Case "Red"
Activity.Color = Colors.Red
Case "Green"
Activity.Color = Colors.Green
Case "Blue"
Activity.Color = Colors.Blue
End Select
End Sub

Sub SetDefaults
'defaults are only set on the first run.
manager.SetBoolean("check1", True)
manager.SetBoolean("check2", False)
manager.SetString("edit1", "Hello!")
manager.SetString("list1", "Black")
End Sub

Sub CreatePreferenceScreen
screen.Initialize("Preferences", "")
'create two categories
Dim cat1, cat2 As PreferenceCategory
cat1.Initialize("Category 1")
cat1.AddCheckBox("check1", "Checkbox1", "This is Checkbox1", True)
cat1.AddCheckBox("check2", "Checkbox2", "This is Checkbox2", False)
cat1.AddEditText("edit1", "EditText1", "This is EditText1", "")

cat2.Initialize("Category 2")
cat2.AddList("list1", "List1", "This is List1", "", _
Array As String("Black", "Red", "Green", "Blue"))

'add the categories to the main screen
screen.AddPreferenceCategory(cat1)
screen.AddPreferenceCategory(cat2)
End Sub

Sub Activity_Resume
HandleSettings
End Sub

Sub HandleSettings
Select manager.GetString("list1")
Case "Black"
Activity.Color = Colors.Black
Case "Red"
Activity.Color = Colors.Red
Case "Green"
Activity.Color = Colors.Green
Case "Blue"
Activity.Color = Colors.Blue
End Select
End Sub

Cheers
Penfound
Learning Slowly

:sign0085:
 

Penfound

Active Member
Licensed User
Longtime User
Just a thought. This is what was added to the manifest file but it doesn't look right to me. Is this where I went wrong?

AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)
 
Upvote 0
Top