Android Question Pausing an Activity from inside the Activity, or from an associated Service Module

TheWind777

Active Member
Licensed User
Longtime User
I am creating an activity, then running a service. Then the service waits for the activity to become paused.

Once the activity is paused, the service watches a time queue with times in it... and when a particular time occurs it starts-up the paused activity and shows just a small non-modal panel with information on it. There's a DONE button on that panel.

I would like it to make the activity return back into a paused condition, again, after they have read the text and after they click the DONE button.

Everthing is working fine except... I can't force the activity back into a paused condition. I wish them to continue with whatever they were doing before the timed info panel popped-up.

Can an activity put itself back into paused mode, again (from the Activity, itself)? Or... secondariiy, can my service module somehow pause the activity once they have clicked on the 'done' button?

---

As I see it... the best way would be to create a second activity. This should kick the first activity into the background because two activities can't run at once. Then, after the second activity runs, have it run Activity.Finish. If I start-up the second activity as an invisible activity (already have that mode for the first activity set-up in the manifest) nobody should even see anything happen.

However, how does one start-up a second Activity? Do I add a second Activity with Project->Add New Module->Activity Module - give it a name, then call it from the other activity using StartActivity(SecondActivityName)?
 
Last edited:

TheWind777

Active Member
Licensed User
Longtime User
I got it. I just added this Sub, then call it when the person clicks the 'Done' button. Pauses the Main Activity, the Service module sees the Main Activity is paused and starts handling the timer queue again. Thanks to the person who posted that in another forum post.

Sub ShowHomeScreen

Dim i AsIntent

i.Initialize(i.ACTION_MAIN, "")

i.AddCategory("android.intent.category.HOME")

i.Flags = 268435456

StartActivity(i)

End Sub
 
Last edited:
Upvote 0

TheWind777

Active Member
Licensed User
Longtime User
For those who find this thread, some day, here is how it was implemented. This is only the bare minimum code. The actual program is gigantic.

This is pretty powerful code as it allows your Main to go into paused mode as the Overlord monitors and waits for some particular thing. Then, it lets you open a MsgBox WITHOUT IT LOOKING LIKE YOU ARE RUNNING YOUR APP. The window shows them something, then the MsgBox goes away, the Main goes back into Paused mode, and the Overlord keeps looking.

If the user was running some other program when the Overlord triggered the MsgBox, then it resumes that activity for them.
 

Attachments

  • TimerQueueOverlord.zip
    40.3 KB · Views: 244
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…