Android Question overlapping activities

engvidal

Member
Licensed User
Longtime User
Hi
I am using the firebase notifications, it runs ok.

At firebaseMessaging service I have this pieces of code:

B4X:
Sub Process_Globals
    Private fm As FirebaseMessaging
    Dim DEVICE As String
    Dim MENSAGEM  As String
    Dim n As Notification
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)

    DEVICE = Message.GetData.Get("title")       
    DEVICE = DEVICE.SubString(8)
    MENSAGEM = Message.GetData.Get("body")       

    Notif.device = DEVICE        'to the notification activity
    Notif.temper = MENSAGEM

    n.Initialize
    n.Icon = "icon"
    n.AutoCancel = True
    n.SetInfo(DEVICE, MENSAGEM, Notif)
    n.Notify(1)
End Sub

Sub Service_Destroy
    n.Cancel(1)
End Sub

When I receive a notification and click on that, the app opens with the notification activity.
Inside the notifications activity I click a button with this code:

B4X:
Private Sub Button1_Click
    Label2.Text = ""
    Label4.Text = ""
    Dim i As Intent
    i.Initialize(i.ACTION_MAIN, "")
    i.AddCategory("android.intent.category.HOME")
    i.Flags = 0x10000000
    StartActivity(i)
End Sub

The notification at status bar is cleared, but when I receive a new notifications, at any time (1,2 or 10 minutes later), I have this issue:

The new activity is overlaped with the old ones

See below

Thanks for help.
overlap.jpeg
 

engvidal

Member
Licensed User
Longtime User
What is the purpose of Button1_Click code? Why not write: StartActivity(Main) ?
Hi Erel
Thank you for your attention

This code is based in your tutorial from 2016

The purpose is to close the notification activity, and send the app to background again.

Vidal
 
Upvote 0
Top