Android Question [B4X] B4XPages - Handle Intent

Alexander Stolte

Expert
Licensed User
Longtime User
How i can handle intents?

I know i can handle it in the main Activity under "Activity_Resume".
B4X:
Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
    If IsRelevantIntent(Activity.GetStartingIntent) Then
        Dim in As JavaObject = Activity.GetStartingIntent
        Dim uri As String = in.RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
        Try
            Log("Loading bitmap from: " & uri)
            tmp_path = cm_functions.GetPathFromContentResult(uri)
            B4XPages.ShowPageAndRemovePreviousPages("b4xp_new_content")
    
        Catch
            Log(LastException)
        End Try
     
    Else
     
        B4XPages.ShowPageAndRemovePreviousPages("b4xp_main")
        'StartActivity(frm_main)
    End If
End Sub

Private Sub IsRelevantIntent(in As Intent) As Boolean
    If in.IsInitialized And in <> OldIntent And in.Action = in.ACTION_SEND Then
        OldIntent = in
        Return True
    End If
    Return False
End Sub
The problem is, if i have for example the 3. page open and i switch to WhatsApp and go back to the app, then the Activity_Resume is firing and the B4XPages.ShowPageAndRemovePreviousPages("b4xp_main") is open again and the page previously are gone.
 
Top