Set focus on a running Activity - android

I have an Activity that keeps running after the HOME button is pressed (naturally) and of-course the focus is in the home screen, and when the running process ends i need to restore the focus on that activity.

Put a notification like GMail, Calendar, AppStore...

Related

How to find HOME key press pause reason from a non-launcher android activity

When HOME button is pressed activity goes pause state
but if the activity is NOT a launcher or MAIN activity then I want to find actual reason why the top activity goes pause state.
Would someone suggest how I can get pause reason from a non-launcher/ non-home activity which is on top before goes to pause due to HOME button press action?
That's ecpected behavior. The HOME button brings up the launcher app. That means the launcher app's activity is now the foreground activity. There is only one foreground activity in Android at a time. That means whatever was previously the foreground activity will be paused, then stopped (unless for some reason part of it remains on screen, which would be weird but possible with a 3rd party launcher I suppose).
Why don't you think it should be paused? I think you don't understand how activity lifecycles work.

Home button in android

I am developing an app
and I need to disable the home button or change his behavior on clicking a button
how can I do it?
I have already tried to use the onKeyDown event and other events
You cannot block the Home button from sending intent android.intent.category.HOME which switches to the launcher but you can set your window to be always on top so the launcher won't be shown.

What is function of main button on real device when quiting an app

I have noticed the splash screen does not display when user clicks the middle button on a real device to quit an application but if user selects back button from main menu to quit app and relaunches the splash screen will display.
Question is what function is the middle button performing compared to the back pressed and is there a way to ensure the splash screen is displayed when the middle button is used to quit an application.
Thanks.
The HOME button takes the user to the home screen (also called the Launcher). The BACK button by default finishes the current activity, which usually results in the user ending up on the previous activity he was in, until he reaches the home screen. The difference is BACK will explicitly finish an Activity, whereas HOME will not.

onResume is not called when I relaunch the app after home button pressed

So I have my main activity, and when you press a button it launches activity2. Once activity2 is launched I press the home button and it will trigger onPause at activity2 and then the desktop of the android device comes to top. Everything's ok.
The problem is: now I click the app icon and instead of coming to top activity2 (the last active), it comes my main activity. So onResume is not called on activity2, but on my main activity.
Isn't it supposed to be called onResume on activity2? How could I make it work?
If you launch an application from the home screen launcher, you are specifically launching the activity which that launcher icon corresponds to.
The behavior you are thinking about is more along the lines of what occurs when you re-enter by way of an activity which is in the back stack.
If you want the home screen launcher icon to put you back in whatever activity you were previously in when that is different from the activity that icon is linked to, you'll need to keep track of that and have your launcher activity transfer you there.
Just to be sure, didn't you override the onKeyDown method which is able to catch device buttons?
Remove the android: launchMode="singleTask" from your launcher activity in the manifest file.

how to go on previous screen from current screen in Android app

How do I go to previous screen from current screen in Android app? I know there is a back button on phone, but it takes me to beginning screen of my app and I want my buttons on app to work for going back to previous screen.
Back button indeed takes you to previously seen activity on screen, that launched the current one (not by means of back button). If back button takes you to beggining screen of your app means that navigation to your last activity was done from it. Try launching an activity from another one different from start activity.
What really can be problematic is ending application once at start activity by pressing back button and discovering the application switching to activity that lauched start activity (not by means of back button). In this case you should just call finish() inside onDestroy() listener method of your start activity.

Categories

Resources