Android Question Click on notification should only bring my app to foreground (to screen) - SOLVED!

artsoft

Active Member
Licensed User
Longtime User
Hi!

The subject of my post explains what I need:

I use the simple notification class to create a simple notification.

B4X:
Dim n As Notification

If n.IsInitialized == False Then
    n.Initialize
    n.Sound = False
    n.Insistent = False
    n.Vibrate = False
    n.Icon = "icon"
    n.Light = False
    n.OnGoingEvent = True
End If

makeNotify("Hello world!")

Public Sub makeNotify(body As String)
    n.SetInfo("MyApp", body, Main)
    n.Notify(1)
End Sub

So far... so good!

I create this notification only (!) in case when the app is in background, otherwise there is no need to do this.

But when I click on the notification, the app is restarted from the beginning.

I only want to bring my app from background to foreground in order to see it on the screen. Nothing more!

How to do this?

Thx and regards
ARTsoft
 

artsoft

Active Member
Licensed User
Longtime User
Ah, I see that the third parameter of

B4X:
n.SetInfo("MyApp", body, Main)

is the Activity which is started when user presses the notification.

If this parameter is an empty string, then the current activity of the app is started.

But the only thing I want is to bring the app in foreground.
Hm...
 
Upvote 0
Top