OS: Windows7 with .Net > 4.5
B4A: 5.20
There seems to be a bug with Intent.PutExtra. When I try to add my user defined Type (Category) to the intent Extras, it does not get added, and this failure happens silently.
After adding my 3 Extras to the intent, I call Log(intent_.ExtrasToString) and the Category object is missing. When the called activity checks for the existence of the parameter, of course it is not there.
Am I missing something?
CategoryManager Activity:
B4A: 5.20
There seems to be a bug with Intent.PutExtra. When I try to add my user defined Type (Category) to the intent Extras, it does not get added, and this failure happens silently.
After adding my 3 Extras to the intent, I call Log(intent_.ExtrasToString) and the Category object is missing. When the called activity checks for the existence of the parameter, of course it is not there.
Am I missing something?
B4X:
Sub Globals
Type Category(Text As String, Notes As String, IsNew As Boolean)
Dim btAddCategory As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
btAddCategory.Initialize("btAddCategory")
Activity.AddView(btAddCategory, 50dip, 50dip, 100dip, 45dip)
End Sub
Sub btAddCategory_Click
Dim intent_ As Intent
Dim edit_category As Category
'Populate Category Item
edit_category.Initialize
edit_category.Text = "Wine"
edit_category.Notes = "Original Notes"
edit_category.IsNew = False
'Set up Intent
intent_.Initialize("", "")
intent_.PutExtra("FromActivity", "CategoryManager")
intent_.PutExtra("cat", edit_category)
intent_.PutExtra("Sub_To_Call", "InsertCategory")
'Check list of Extras, and cat is missing
Log(intent_.ExtrasToString)
intent_.SetComponent(GetPackageName & "/.categorymanager")
StartActivity(intent_)
End Sub
Sub GetPackageName As String
Private r As Reflector
Return r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
End Sub
CategoryManager Activity:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim sub_name As String
Dim cat As Category
cat.Initialize
Dim StartingIntent As Intent
StartingIntent = Activity.GetStartingIntent
sub_name = StartingIntent.GetExtra("Sub_To_Call")
Log(StartingIntent.HasExtra("cat")) 'Always False
'cat is always null
cat = StartingIntent.GetExtra("cat")
Log(cat = Null) 'Always true
'CallSub2("", sub_name, cat)
End Sub