what i need is i have 3 activities i have navigated from 1 to 2 and from 2 to 3. now at i am at third screen and now if i press home button all the activities will be paused and application goes into background. and when i open the app by long press on home buttton passcode screen will appear and when entered pas code now i need to get 3rd activity screen from where i pressed home button. How can i do this. how could i do this
i referred Saving Android Activity state using Save Instance State this link
Related
I have an application which always has to start with a splash screen.
But after the splash screen, I want that it should go to the last activity that was visible before the application went to the background.
Also, I would like the same behaviour when the app icon is clicked.
So lets say the user was on Activity5 and then he pressed the Home button.
Now if he clicks on the App icon, then the app should start with the Splash screen but then return back to Activity5.
Could someone please help me with the above?
Thanks and regards,
Sunny
For showing splash screen and starting the same activity,when user closes your app on home button pressed,you need to override the onPause() and onResume() ,of the activity . onPause() will be called when user will press the home button,Usesharedpreferences,to store some value referencing the current activity in SharedPreferences and when user comes back to your application onResume will be called
where you can retrieve the value of the variable of sharedpreferences show up the splash screen and start the same activity again.
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.
I had a small problem
1.In my app I have both widget and application.
2.If a person uses the widget he will enter into the gallery and ask him to select the image whenever he select the image it will placed as wallpaper.
3.where as in app he will have different choices to use(ex:customizing..etc)
4.So whenever the person used widget and longpress on home screen and selected the app it was opening gallery which is used for widget.
5.But according to my requirement whenever he long press on home screen and selected the app it should go to main application but not widget's one....
Im stugling this...is there any solution for this...hope i have given clear description...if u dont understand plzz let me know
Basically the homebutton puts the app in paused state you can perform the operations by overriding onPause method.
whenever he long press on home screen and selected the app it resumes from the paused state
you can define any action when app resumes in onResume method.
This is as designed by Android,. Long press of home shows you recent apps with saved state.
so since the user has used widget and then long presses to select app. it will show last saved state that is widget gallery.
I am very new developer for Android application so please ignore if there is some technical mistakes in my question.
I have five screen (Home, SR-1, SR-2,SR-3,SR-4 ) in my Android application and I can switch any screen at give time.
When we are pressing device back button it will take we to the previous screen where I was lastly.
But whenever I am pressing Home it will take me to landing screen If in this state I am pressing device back button I will take me to previous view but I want to remove this state maintenance.
(i.e. : When I am coming to Home and I pressed back button It will exit from my application)
Thank you
for each activity: you can add in AndroidManifest.xml
<activity android:name="nameofActivity"
android:noHistory="true"></activity>
From android pressing back button should exit the app :
Immediately after you start a new activity, using startActivity, make sure you call finish() so that the current activity is not stacked behind the new one.
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.