Displaying MsgBox from Service with Intent?

Snant

Member
Licensed User
Longtime User
Hello to all.

I am a newbie in B4A but i have studied the documentation a lot as i have searched the forum for hours.

I am trying to create a service that runs in the background. I realized that i can't display any info from the service but i have to inform the activity to display any data i want.

But how can i display a MsgBox when the service is running but the activity is paused? For example, i want to display a MsgBox (AlertDialog) every time the phone rings. I tried a lot to use Intent with ACTION_VIEW but with no success.

What i am missing?

Thank you.

:sign0144:
 

Snant

Member
Licensed User
Longtime User
Thank you for the answer. I already know that ToastMessage is the only dialog that can be displayed from Service but i was wondering if there is any way to display MessageBox from an intent.

I have tried displaying e.g. WIFI_SETTINGS and it works but i don't know if this could happen with a MsgBox using an intent.

Thank you.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
i was wondering if there is any way to display MessageBox from an intent.
I don't understand what you mean by this but you got it right in your first post.
i have to inform the activity to display any data i want.
Only activities can display stuff.
 
Upvote 0

Snant

Member
Licensed User
Longtime User
Hmm, i'm sorry, maybe i haven't completely understood the meaning of intents.

Is this display-only-from-Activity issue is only for B4A? Because there are plenty of apps that act as services, that display information like AlertDialogs with buttons and interact with the user.
 
Upvote 0

Snant

Member
Licensed User
Longtime User
That's right Erel, i thought about this but i must admit that i don't really know how to call a custom activity from an intent.

Thank you.
 
Upvote 0

JMB

Active Member
Licensed User
Longtime User
You could use CallSub([Activity],Sub) from inside your service to allow your activity to do the UI stuff.

If you had a Sub called "Showinfo" inside an Activity called "MainAct", you would make the call:

CallSub(MainAct,"Showinfo")

That would allow your service to communicate its progress to the main activity which would then update information as required.

You do have to make sure that the Acvtivity has not been suspended of course

JMB
 
Upvote 0
Top