In my application when i install it from APK, and start it , and press home button to redirect it to background, than again open the application through its app icon, than it restarts from the begening. Means application restarting when we go out through "home button click" and come back to application
How to stop this please let me know.?
I dont want to restart my app when I go out thru home button click, the app must restart only after when I exit from application.
An answer can be found here: Android application restarts when opened by clicking the application icon
It can be fixed by adding this piece of code in the onCreate() method of your first Activity:
if (!isTaskRoot()) {
finish();
return;
}
The bug is explained here: https://code.google.com/p/android/issues/detail?id=26658, and the fix is given in comment #14 :)
First, there is no "exit from application". Then read on activity stack here to really understand how the activity is managed.
Related
I'm working on a launcher app that basically launches other installed apps on the device with an explicit intent and I have a edge case scenario:
An Activity (Act) creates an intent of an application (App) and starts it by calling startActivity(intent).
App get launched, my Activity going to "stop" state.
After a while I want to get back to my application so I click on "back" hard button that closes App and bring my Application to foreground (resume state).
This is the wanted behaviour.
Here is the edge case:
If I click on the "recent applications" hard button (square icon) while on App is launched, history stack is lost, and when I return to App, and click on "back" hard button - App exists to the Launcher screen and onResume of my application is being called.
I searched the web for a solution for couple of hours now, maybe I'll find a solution here.
Thanks
It seems to me you should set android:alwaysRetainTaskState true in your root activity.
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.
I have made an application named TicTacToe having AI. The problem is when I press my phone's power button and press it again to start my phone - what i notice is my app is closed and I see the home screen. I want my app to still run even after pressing the power button. ThankYou in advanced!
I think the app is minimized. Long press the home button the app is shown then click the app it will resume.
If by power button you do not mean turning the phone off, you can simply make use of the onresume and onpause functions. More detail on this: http://developer.android.com/training/basics/activity-lifecycle/pausing.html
If this is not working for you, try to log the runtime errors that the app gives and see if there are bugs in the code.
I am developing an app that is having function to upload images to instagram. So when i upload the image to instagram and press the home button,the app is closed and when i ma relaunching the app it is starting from the main[ splash screen] activity.
In that application i am having option to take images from gallery and the camera. So when i press the home button and relaunch the app it should start the activity where i can chose the images.
I have tried a lot. If anyone have the solution please help me out.
By default last activity will open when relaunch the app.But some device it will not happen.
I don't know the proper reason but may there is settings problem in that device.
By default the last activity will be shown when the app is restarted. Unless you have added any 'no history flag' or:
android:noHistory="true"
Set noHistory to false. ..
I'm trying to debug an issue and I'm not sure what is going on.
My application is launched from application A (this is not mine, someone else's, so I don't have any source code)
When I click the back button on my application, I land on the Android home screen rather than going to the application that launch me. I checked all the flags in the intent that I receive, and everything is turned off.
Now if I launch my application from any other application, then pressing the back button goes back to the application that launch me.
I'm not sure how to debug this issue. Any ideas?
Application A might call finish() once the Intent is sent to start your Activity. Then the Activity in application A that started the Intent to launch your Activity will go through onDestroy() and will be removed from the backstack, so when you press the back key you will go to the home screen if the Activity in Application A was the first Activity launched by Application A