I have an android app with a single activity which is launched with SingleInstance mode. The app has a countdown timer. When the app is minimized and goes to the background and other apps are used, I want to bring my app to front when the countdown timer finishes.
I tried:
StartActivity(Intent.AddFlags(ActivityFlags.ReorderToFront));
But it does not bring my app to front. However, it may reactivate another app which is at the top of all minimized apps.
I have tried other ActivityFlags but they don't bring my app to front when it is minimized and another app is used. How can I bring the minimized app to front when other apps are used?
Related
Currently I am handling onTrimMethod(int level) in my app with ComponentCallbacks2.TRIM_MEMORY_COMPLETE and ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL. I get this callback easily with low end devices when my app is running in background and simultaneously I am playing games.
In that I put Runtime.getRuntime().exit(0); to kill the app in background only so that when user taps on app (running in background), app will restart from launcher activity. I don't know it kills the app or not but when I open the app, first it shows dialog with "Unfortunately, app has stopped" and app does not restarts.
If I start the activity from this method, it will launch the application and bring it to foreground without any user interaction.
I tried some other ways too to kill the app. They are System.exit(0); and android.os.Process.killProcess(android.os.Process.myPid()); but none of them are solving my problem.
So, what to write in onTrimMethod() or how to handle in other way so that when user opens the application (brings to foreground from background) it will start from the first activity?
I found similar questions, but I can't seem to make any solution work for my scenario. I am new to development, so please bear with me.
In one of the activities in my app, there is a timer. I would like the following:
1) To have the timer continue to run in background even if user switches to other apps OR another screen within the app
2) To have only one such instance running from the app
3) Once the timer finishes, the app screen is back on top (similar to timer in the android stock clock app)
I am using Android tablet to test my application.
I press the home button to put the application to background.
Now, if
I launch the application from recent apps, it will open the same
screen, I was on, and will not restart the application.
But, if I launch the application from my apps, it starts a new
instance of application. This time it restarts the application
from splash screen, and when I check the recent apps, it shows
2 instances of my app.
I want only one instance of the application to be running, on my tablet, at any time. Please help...
Android 4.0 which is now allow the developer to disable the application.
Then I developed a service to bring to application to foreground when the user click the home button.
Now I can bring the application to foreground successful.
But each time I opened the application and then click home button.
it will show the launcher and delay 5-6 second to bring to application to foreground.
I find that the service retried a few time to bring the application to foreground.
But when I click the button on the launcher, it will bring the application to foreground immediately.
Any solution to fix the delay problem?
Thanks.
I am building an Android application in Flex 4.5 and I am testing on a Samsung Galaxy S phone.
My application uses GPS and also Google maps.
When I run the application, and I try to close it, the application keeps on running in the background. I would like the application to stop when the user presses the device's home button or when the user clicks the back button until they leave the application.
How can I make the application shut down in both the cases?
This is how Android applications are supposed to work. See here: http://developer.android.com/guide/topics/fundamentals/processes-and-threads.html
Your application's process is in either the "background" state (if the user pressed how) or "empty" state (if the user pressed back).
For starters, you can try using the Activity noHistory flag in the manifest. This will make sure an Activity is finished if navigated away from.
http://developer.android.com/guide/topics/manifest/activity-element.html#nohist