Start same android last activity on relaunch after closing the app - android

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. ..

Related

Launcher activity open agains when the app is opened again from another app

In my app, it starts with the Splash Screen. Then the user login and already reach to Dashboard activity. I finish the Splash and Login activities from the backstack.
But when the user open the app again from Zapya, the app load new splash activity on top of the existing activity stack.
When the user tap on Back button, the splash activity disappears and the Dashboard activity display again.
According to my knowledge, the app should normally show the topmost activity when it already exists in the memory.
Please, suggest me is there anythings should I modify or configure?
Edit: This is a known bug and there is various ways to solve this problem. I've solved this problem by this stackoverflow answer.
You can also learn in the following post too.
App restarts rather than resumes

Close app when minimized

I have similar problem like this.
On start my app displays a splash screen and checks via network if the current user is still premium.
My problem: I started my app right before I went to bed and minimized it by pressing the home button. In the morning I launched the app again and it resumed the activity from the night. The app never really quit, my splash screen was not shown and and it couldn't check if the user is still premium.
So how can I achieve my app to be closed after a certain time (e.g. when the app is minimized)?
But the problem is there is a portion in the app where I can view videos in full screen and here I use android's default player. So when the app is minimized while watching and then again open the app onResume will not be called and cannot check whether it is a registered user or not. The video player will continue to play the video. Is there any method so that I can kill the app when the video is playing and minimised?? is there any method which is called when the app is minimised using home key press?? Is it possible in every device to detect the home keypress event and write some code there?? Please help with some fresh ideas!!!
Now I know why my reputation is always low. Thanks Dan Hulme. You are right I just want to use the app lifecycle correctly. I want to use onRestart not onResume. And that have done the work for me. Thanks all.

Android - Application Launchs the Main Activity always

We have an issue with android application. We created a Sample project which has 3 screens. LoginScreen, WelcomeScreen,HomeScreen.
When user login, will navigate to Welcome Screen and from Welcome screen place a button to navigate to Home Screen.
Application works fine as expected. We are facing an issue with the Device's Home Button. When user clicks on Home button the application quits and device home screen will appear to the user, and when the user opens the application again, the application should open the page, from where the user quits.
If the user quit from WelcomeScreen, welcome screen should be launched when the user open the app again, if its HomeScreen, then HomeScreen should be launched. When the connect the device in my laptop and try running directly application working fine as expected, but Issue is with copy paste the apk file.
If i copy the apk and paste that in my Device storage and run the application, its always opening the LoginScreen when the user quits from welcomeScreen or HomeScreen and click on the App icon again. Can you please help me to resolve this? Thank you so much.
I think you need to uninstall the application from your device delete all apk from the devices and then you should build directly into your device so that you can get the latest version of app installed in your device.Do this I hope that it will work.

All activities are closing on home button press

Thank you for taking the time to help.
I have created an Android application thats starts up with a splash screen, then depending if the user is logged in, the application opens either the login or main activity.
When the user presses the home button and then click's the application icon I would like the application to resume at the last activity the user was at (For example the login screen).
This works fine when the APK is installed onto the device via Android Studio, but if I try to install the APK manually (the exact same APK), every time I press the home button and reopen the application it acts as if I killed and then started the application (The splash screen starts again).
Any idea why this could be happening?
Thanks
add following line to your manifest in your launching activity means 1st activity
android:launchMode="singleTask" android:clearTaskOnLaunch="true"
on other activities add:
android:finishOnTaskLaunch="true"
What you want to achieve is already the default behaviour of Android, but there is one possible way this can happen which is if your device need more space in memory then it may kill other applications which are on pause state. I believe that you're running into that situation and i'm afraid you don't have anything to avoid that.
Refer to
Edit: By the way, you can check that by logging something onDestroy and onPause method to see when your activity pauses and when it gets destroyed by system. Until it gets destroyed, you should be able to see the behaviour what you seek.
I met the same problem.
Сhange android:launchMode="singleTask" to android:launchMode="singleTop" helped me.

Android App Launcher strange behaviour

hi guys i am finding the strange behaviour in android while launching the Application. Let me explain the senerio. I am launching my application from android's launcher page and my application starts and runs fine and after few minute i press home button and go to android home page and then go to launcher page and again select my application and it is starting it again from first but it should have resumed from the last place where i left. And when i press back button on the launch screen of second instance of my app i am able to go back to the last page where i have left. I am more confused about what was happening and it too happens sometimes only not every time. Hope you people could help me sort this problem, Hoping for better responses. Thanks in Advance.
Edit #1:
It is not happening in all the device it happens only with Samsung and Sony but works fine with LG and HTC.
To keep an activity running in the background is not in your hand. When you press the home button, your current activity goes to the background and can be killed (onDestroy() will be called) at any time depending on the need for memory of the other applications you launch.
The more apps you launch, the more chances of killing your background app is.
The behavior may be device specific - try saving your game settings in a persisted location within the 'onPause()' function, and retrieving it on 'onResume()'. Then it doesn't matter if a new activity gets launched or the old one gets called.

Categories

Resources