How to bring a program to forefront from a service.

LittleBritaly

Member
Licensed User
Longtime User
I have one activity which starts a service which intercepts text messages.

I would like the activity screen bringing to the foreground to display some information, in other words if the "program" is in the background, I would like it bringing into view without user intervention.

I could use kiosk mode to override everything else, but would prefer it to sit in the background hidden and only if given the correct command by sms become visible.
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Calling StartActivity(..) from your service will show the activity.

The more standard approach is to add a notification and let the user decide when to start your activity.

Greetings, all.

Thank you in advance for answering my question.

I know and have tested that StartActivity(..) from a service module will bring the activity to the foreground.

What else could be done -how do I add a "notification" that requires a response from the user?

The more standard approach is to add a notification...

As usual, I am grateful for any and all help.

Best regards.

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Erel.

I initially searched for Notification Object and found the desolatesoul and bar-x advanced Notification Libraries. I could not find how to issue a B4A "core" or basic Notification... :( And how do I add a "notification" that requires a response from the user?

Best regards.
Sandy
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I think you need something like this in the service module although my knowledge of services is shaky:
B4X:
Notification.SetInfo("My App", "Hello Florida", Main)
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Mahares.

This is the first time I use a Service.

How do I declare Notification? Is it part of a library?

I initially searched for Notification Object and found the desolatesoul and bar-x advanced Notification Libraries. I could not find how to issue a B4A "core" or basic Notification

Best regards.

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Mahares.

I do not know how I could have missed it.

Best regards.

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Hello, Mahares.

It works from a Service Module:

B4X:
Dim Notification1 As Notification
Notification1.Initialize
Notification1.Icon="icon"
Notification1.Insistent=True
Notification1.SetInfo("Look and Look Again", "How could I miss it?", Main)
Notification1.Notify(1)

The Notification1.Insistent=True keeps beeping until user acks notification.

Thanks again.

Sandy
 
Upvote 0
Top