Android: Bringing activity to front at end of timer and resume app - android

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)

Related

Bring app to foreground from background, Xamarin Android

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?

Launch android app after start and block other apps

I'm facing the following problem. I want to make an android device to run only my application. All other apps and phone feautes should not be available to a user.
The reason why I want to achieve this is simple: I want to destribute devices with preinstalled application to my client but I don't want to let them use all phone featues.
This could work this way: just after android boots my application is launched automatically and than somehow all other staff is blocked.
Do you have any suggestions how to achieve that? Is it possible? Do I need to root a device?
I hope you get my problem. Any advice you can give will be greatly appreciated.
This is a bit crude way. But see if it is of any help.
If you create your application as a launcher it will start on boot(using system broadcast BOOT_COMPLETED).
Then you need to override all the three android buttons Home, back and recent apps.
To override back button you just have to override the onBackPressed() method.
For home button you will start a service which will run in background. This service will check if your app is in foreground or not. if not then it will bring it in foreground. so when the user presses home the service will sense the foreground app isnt yours and launch it.
But for this switching back of your app android takes approx 3 to 5sec. In that period of time you can display a warning text which will block the user from stopping the service from settings.Also if you remove the activity animations then it will appear seamless.
For recent apps button the above trick will do. If the user tries to close the app using this button your background service will sense it and launch your app.
so its the background service that does all the trick. if you some how stop the service or uninstall the app you are through :p

Android App Icon intent category seems inconsistent

Clicking my app icon will sometimes take me to the launcher activity, but other times it will resume the activity where it left off (emulates the behavior of clicking the application in recents).
I've read (can't find concrete docs about this, other than a one off post from 3 years ago by Diane Hackborn) that after about half an hour, the OS will make sure that when you click the app icon, it will relaunch the app, but sometimes it seems to do this directly after I exit the application (with the home button, not the back button as that will call finish on the activity).
Why is this?
Is there any way to force the launcher activity in the Android OS without killing the app first then restarting it? I need to test how my app handles the launcher activity after the application may already be running.
Android will free up memory whenever it feels necessary. For that, it will kill inactive apps. If your app goes to background, at some point Android will probably kill it. Matter of time.
You can kill your app, or you can make it kill itself when it goes to background. No more options.
in order to make your app kill itself, you should override the onPause() method (which is always called when the app goes to background) and add in it a call to onDestroy().

Issue when application is running in background

I am facing an absolutely abnormal problem in my android application.Scenario is like that:-
I have a main activity in which a button is placed named as SOS .On long press the button,another activity is launched in which a timer starts.
The timer is executed in a service so that it can be easily runs in background also. Now the timer is running and when i pressed the home button of the device the app goes in background.Till now its fine.Now the problem is that when I again launch the application by clicking the application icon.The timer is not visible.
The application starts again from scratch.but the timer is still running in the background.What I want that,the same screen should be reopened when the application is launched again that is Timer screen.Now this problem is not arises when I deploy the build from the eclipse.Everything is working fine in this case.
But when I deploy the build in the device after downloading from the mail account,the above problem arises.
Please help me to sort out this problem.
Hope you know the behavior of Android OS,
When your Activity is in background and OS need to free some memory it will kill your app and start it again when you need.
If everything is right in your logic then might be your app being terminated by OS.

Forced to stay only mine app and can not open another app

I am developing one android application. In that i need to do below task. Can anyone suggest me how to do below task?
I want to force to user to stay on mine app, he/she can not open
another app. Only mine app is visible to top?
How can i achieve this?
Any help is appreciated .
I had a requirement where I need my App to run in foreground always, so that no other App should be running other than my App. Also, I had created a menu inside my App to Exit the Service that I created that keeps my App running always in foreground (not in this demo).
I had created a demo for the same in my github named as MyBackgroundServiceDemo.
Notes:
My requirement was for Tablet only.
I disabled back button of my App.
When user presses home button it will stay to home for 5 seconds (which is default by Android).
My Service keeps running constantly to keep track of Apps that are running.
I had modified the Service according to my requirement later on to keep track of my requirements. Same way you also modify the Service to meet your requirement.

Categories

Resources