Android Question StartActivity without Activity_Pause in then main?

Michael Müller Anywhere

Member
Licensed User
Longtime User
Hello,
I want to start a PDF-/Image-Viewer in my App with StartActivity(intend) - That works
Is it possible to start this new intend without pause the main?

I aks because my App crashes (Firebase Service destroy with the error message:
android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{cab6274 u0 lunasoft.elsmobile/.firebasemessaging}
when I receive new mesages via AsyncStreams in the meantime I watch the image or read the PDF.
Because I can't find a solution for the crash I hope that the crash not occours when I can view the PDF / Image
and prevent my main to "pause"

(I know this is very very unprofessional)

Thank you!
 

DonManfred

Expert
Licensed User
Longtime User
Is it possible to start this new intend without pause the main?
you can not start another activity without the current activity to send to back (activity_pause is called). At least not when using the standard activity lifecycle.
 
Upvote 0

Michael Müller Anywhere

Member
Licensed User
Longtime User
@agraham

I have installed Erel's Demo QR-Project
and addet this code to test it:

Adding Code:
Sub Button1_Click
    Page2.SetQRString(TextField1.Text)
    B4XPages.ShowPage("page 2")
   
    navi("53.1" & TAB & "10.3")
End Sub

Sub navi(Koordinaten As String)
    Dim Intent1 As Intent
    Dim lat As String
    Dim lon As String
    Dim map_URI As String

    Dim feld() As String

    feld = Regex.Split(TAB, Koordinaten)
    
    lat = feld(0).Replace("," , ".")
    lon = feld(1).Replace("," , ".")
        
    If lat.Length > 2 And lon.Length > 2 Then
        map_URI= "geo:" & lat & "," & lon & "?q=" & lat & "," & lon    'MAP
        Intent1.Initialize(Intent1.ACTION_VIEW,map_URI)
        Intent1.SetComponent("googlemaps")
        StartActivity(Intent1)
    End If
End Sub

Now I can return to my app while the google app is still running!
Thank you for this tip.

@DonManfred
thanks, then I don't have to look any further
 
Upvote 0
Top