Question

After I made some researches, I found out there is only one way to restart an app and bring it to foreground from background. They say I should use services to do that. But all of the answers refer to developer.android. And I'm not yet able to use developer.android. Don't ask why.

What I want?
When user goes out of my app (go to another app, menu, or going to settings) somehow, listen it with BroadcastReceiver or services. Then bring my app back to foreground.

What I did so far?
I've tried some code snippets but they didn't give me the solution. I guess I didn't understand the basic of services and broadcastreceiver. This is the only point that I stuck with.

I'm sure it will be a few lines of codes. I'm waiting help from you guys.

Was it helpful?

Solution

It is definitely possible (Surelock does it). But i guess u cannot do it using BroadcastReceiver as there is no broadcast sent by the system when an application is launched.

You can bring your activity to the foreground by starting an intent of your activity from your service. But your challenge is to determine when you should start your activity.

If you want to run a single activity "always on top" then you can use this technique. It doesn't even require Service implementation.

Hope this solves some of your issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top