Hi All,
So I've got a couple of Activities.
Activity A - Allows users to create and saved messages
Activity B - Lists all the messages with the ability to edit each stored message.
I want the edit button on each of the items shown on Activity B to launch Activity A and pass the stored message.
I have the following code:
Manifest: (NewScheduledMessageActivity is Activity A for reference)
In Activity B:
In Activity A:
I can see while debugging that the Intent received by Activity A has no extras. In fact, all the member fields are null while only the Action URI is correctly set to com.zarhouni.messagingpa.EDIT_MESSAGE.
The InitIntent.HasExtra("PendingMessage") check doesn't evaluate to true.
What is the small thing I am missing here?
Thanks!
So I've got a couple of Activities.
Activity A - Allows users to create and saved messages
Activity B - Lists all the messages with the ability to edit each stored message.
I want the edit button on each of the items shown on Activity B to launch Activity A and pass the stored message.
I have the following code:
Manifest: (NewScheduledMessageActivity is Activity A for reference)
B4X:
AddActivityText(NewScheduledMessageActivity, <intent-filter>
<action android:name="com.zarhouni.messagingpa.EDIT_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>)
In Activity B:
B4X:
Sub EditButton_Click
Dim btn As Button = Sender
Dim EditIntent As Intent
EditIntent.Initialize("com.zarhouni.messagingpa.EDIT_MESSAGE","")
EditIntent.AddCategory("android.intent.category.DEFAULT")
EditIntent.PutExtra("PendingMessage",PendingMessage)
StartActivity(EditIntent)
End Sub
In Activity A:
B4X:
Sub CopyExistingValuesToFields(InitIntent As Intent)
Dim SavedMessage As PendingMessage = InitIntent.GetExtra("PendingMessage")
LblDate.Text = SavedMessage.Date
LblTime.Text = SavedMessage.Time
TxtMessage.Text = SavedMessage.StrMessage
TxtTo.Text = SavedMessage.StrTo
End Sub
Sub Activity_Resume
Dim InitIntent As Intent = Activity.GetStartingIntent
If InitIntent <> Null Then
If InitIntent.HasExtra("PendingMessage") Then
CopyExistingValuesToFields(InitIntent)
End If
End If
End Sub
I can see while debugging that the Intent received by Activity A has no extras. In fact, all the member fields are null while only the Action URI is correctly set to com.zarhouni.messagingpa.EDIT_MESSAGE.
The InitIntent.HasExtra("PendingMessage") check doesn't evaluate to true.
What is the small thing I am missing here?
Thanks!