Android Honeycomb Home Button kills app - android

I have an app where you enter some data. The PRE-Honeycomb behavior is the following:
back button seems to kill the app, all input data is lost
home button seems to pause the app, all input data is still there after the next start of the app
For Honeycomb the behavior for the home button seems to have changed. After pressing the home button and start the app again all input data is lost. Is that intented? The problem is that I can override the back button to save data, but reading various posts I cannot override the home button. Is that an expected behavior or a bug? How to deal with it?

Any time your app is not visible, it is eligible to be stopped by the system. You shouldn't assume anything about your app still running in the background if it's been hidden. If you want to guarantee data is not lost, make sure you save it somewhere in onPause() and restore it again in onResume().

Related

Android studio App home button and re open

Android studio home button problem.
I have so many activities, when I press home buttom in any activities.
Then if I restart my app.
it started from splash activity(logo activity).
However, I want to start this from activity where I pressed home button.
Can anybody figure this out?
By default, Android handles this behavior. When you press the home button, the app should go to background and at the next time when you open it, it should start from where you left off. But, Android's memory management is designed to automatically terminate minimized apps that have not been accessed in a while when memory is needed for newly launched apps.
If there is enough memory available and still your app gets terminated, that means you are not using the API's correctly. Please read this [article] to know how to handle onPause() and onResume() to achieve this behavior.

home button pressed

What exactly happens when I press home button in Android?
Because when I open it again after home button pressed, it has series of bugs.
I need to know it to track down the point that causes that bugs.
UPDATE:
when pressing home button, application goes to background and onPause() is called and saves the state of UI, however it does not save state of application, like variables, custom views. And you have to save them manually, as Oren explained.
When you press Home Button your Application/Activity goes in background and when you open it again it resume from the same position as it was until it was being killed/closed by the OS.
Activity Life Cycle will give you a clear idea about it.
Technichally? Anything can happen, from just onPause being called, to the device killing the app to free up memory, to the user shutting down and restarting the device. Your app should handle all of these possibilities.
Further reading : android activity lifecycle

Adobe Flash Builder Flex Mobile Android: Avoid that user can close the app

I am developing an app for android. It is not always clear to me when the app will be terminated by the OS. Sometimes it happens when you press the back button and sometimes when you press the home button. What is the logic behind this?
My app must be keep activated during a long period (when you run it the app must stay resident). Also another question is if it is possible to popup when an event comes in and activate the screen and bring it to the front.
Does somebody made this already? Or is there more information about this (how to do it). Search the internet but doesn't find some useful things.
Pressing the Back button on the main activity will finish and exit the app.
Pressing the Home button will pause and leave the app in the background, it will return to the previous state when it's restored.
Override the onBackPressed() method on the main activity if you don't want it to quit when the back button is pressed.
If you want an event to occur when the screen is shown, override the onResume() method and do the checks and event required in there.
Being that your answer is with Flex the issue is that you need to listen to the stage's keyDown event.
stage.addEventListener(KeyboardEvent.Key_DOWN, yourHandler);
Then you need to response to the back button and inhibit this - if your intent is to stop the back button.
private function _onStage_keyDownHandler(event:KeyboardEvent)
{
if(event.keyCode == Keyboard.BACK)
{
event.stopImmediatePropogation();
event.preventDefault();
//your code here
}
}
And one more moment - android can close your app when it thinks that it need more memory for more recent apps.
And you may need to use native extensions or even develop your app in java if you want to implement reliable resident behavior.
Update: java service+ air ui example:
http://www.jamesward.com/2011/05/11/extending-air-for-android/
end of update
And you must know that air apps eat at least 30mb of memory(if they are empty and do nothing), normally they will start from 50-70mb. I guess that no user will wish to allow another 70mb of his memory-hungry device to be eaten by something not critical.
And for automatic maximizing of your window you may need root access.

Need clear understanding of Home vs Back events

I would like to know the "idea / use" of the home versus the back button. I mean obviously the home button takes you to the home screen and the back button takes you to the previous screen. What I am trying to understand is what the users / development community expect.
In other words when a user hits home in my application should I handle that event and terminate the application? Is that what the user has grown to expect or just the opposite?
Same for the back button. Do users expect the screen being departed from to be lost much like a web page would be?
What I am getting at is trying to make sure my app behaves consistent with what the user community has grown to expect.
TIA
JB
Home Button will put application in onPause() -> onStop() , again when you relaunch application, the activity will execute the method: onRestart() -> onStart() -> onResume() -> i.e. activity life cycle
and
Back button finishes or kills the current Activity on click of back button and jump back to the previous Activity which is in stack.
Generally I'd say that pressing home is like minimising on a desktop. So I would expect the app to return to where it was.
If it acts like this then I can easily switch between apps if I need to get information from them.
Pressing back should take me backwards through the things I was doing in the app and when I reach the end of the stack it should close.
home button pressing causes an intent that is used by the the launcher app to show itself .
back button is a real event that can be caught within the current app .
in general , home button should hide all apps and go to the launcher , while back button should go back to the previous screen the user saw (finish the activity or dismiss the dialog) , and go to the previous app (task ) in case the current one doesn't have any more screens to show .
The community expects that if you press the home button, your app will go to the background and be resumeable from there. Multitasking is in the core of the Android OS. To finish your activity or app when home button is pressed is unusual to android users.
The back button is when you want to go one step back, like in the browser as you said. If you are know to IOS it will act like when you press the back button there in the top left corner.
Hope this helps
I would like to know the "idea / use" of the home versus the back
button
Let me Discuss for Back Button First.
The back button behavior is inconsistent.
for Users, it is very easy to use.
for Developer, to understand what actually pressing the back button does it isn't so easy.
The back button can perform any of the following actions as Officially said by Android site :
Go back to previous screen (activity)
Dismiss a popup
Terminate a long running process
Close on-screen keyboard
Go to previous page on browser
Exit the running app when on the last activity
Return to previous app when on the last activity and the app was launched through intent from another app
When Problem Occur with BACK button?
An added problem comes when trying to understand when the back button
cancels a running operation and when not. For example, when installing
apps from Android market tapping back takes users to previous screen
and leaves the installation process running in background. I know
there's a rule that back cancels operations that are presented users
as popup progress indicators and any other cases it is used to
navigate. But is that what users expect? Do users have to think before
pressing back to understand what is going to happen?
Home Button
Home button will take users to home screen and swiping in the
multitasking menu will kill the apps if needed. As on ICS on new
phones all the buttons are on-screen the back button could simply get
disabled when user reaches the last activity if the app was launched
from launcher icon. This would make some of the confusion to make away
but still wouldn't solve all the problems.
Finally , Don't Make Users Think Navigation is some what more important. Users should always know where they will endup without thinking.
I don't think there are easy answers for this problem but I think it may help you to find workaround for your problem according to your app.

re-lunching an android app from list of recent apps vs pressing on the app icon

I have written an Android app that plays some audio. There is a stop button on the app GUI that when I first lunch the app works fine.
However when I go out of the app while audio is playing and come back depending on how I came back the STOP button works or not.
If I come back to the app by holding the home button and seeing the list of recent apps and choosing my app from there, then the STOP button works. But if I click on the app luncher icon the STOP button does not work.
What is the difference between these two method and how can I make the re-lunch of the app by pressing on the app icon to behave similar to when I re-lunch the app by choosing the app from the list of recent lunched apps.
Without seeing the code we can't be entirely sure, but it sounds like what is happening is that your activity is you set up an action listener (setOnClickListener) on your stop button in your onCreate() method.
The onCreate() doesn't get called again if the app is never recycled (Android will do this when your app is put into the background) and started over.
When your app is put into the background onPause() will get called, then coming back from that you will get a call to onResume(). If your app has been in the background longer or Android needed more resources you'll get a call to onStop hitting the home button and onStart when the app opens again.
You'll need to do some investigation into your code as to why your listener goes away, but now you have the hooks to make sure they are connected back up when you're app is back.

Categories

Resources