Splash Screen at End of Android Application - android

I want to create an ending splash screen that should come up at the end of the application as i have exit button in the last page so i want that when someone clicks on exit button a good bye page should appear for 3 seconds having a image and soft music tone and then application should automatically end, i am confused how should i fix this end page in my application, i am thinking to code at click event of exit button and via intent start the good bye page and then how to code?, so that it should exit out of application after 3 seconds of soft music, also what changes i have to make in the androidMainfest file for that.

start a CountDownTimer in your ending splash activity's oncreate method, set it to finish after 3000 milisenconds and write activity.finish in its onfinish event handler. also, you need to call activity.finish() in your last page activity after calling startactivity of the good bye page.

Just start the ExitActivity with the button and then run an CountDownTimer for 3 seconds which then calls the intent for the HomeScreen like here

Related

Android - How To Override the "Back" button so it doesn't stop() my background Activity?

Android - How To Override the "Back" button so it doesn't stop() my background Activity? For example if my Quiz app run the countdown timer. If user click on back key the count down timer are in running . I want Back key not effect on timer stop or pause
I think a better solution would be to move the timer to a separate service that runs independently of the Activity you are referring to.
Or you could save the state of the activity once the back button is pressed, and restore onCreate/onStart.

Continue timer even back button or another activity is opened

I'm trying to make a CountDownTimer App with some influence from the Android documentation. The App has a button and textview. When the button is clicked the countdown starts and when the same button is clicked the countdown timer stops. The timer is getting stopped when I press the back button or navigate to another activity in the App.
I want the timer to continue counting down even when the above operations are performed and the activity should be destroyed only when the timer isn't running.
How can I do this? Can anyone give me an in detailed answer?
Whenever you navigate to next activity your current one goes to onPause()(if not finished()), and the UI thread goes to sleep, so in order to update your timer when you leave and again come back to the activity is updating the UI whenever your Activity resumes itself(which is what onResume() is for). Trying using a boolean to detect pause event this is because when the activity starts it calls onResume also.
So summary is whenever leaving current activity store a boolean and while returning check it in onResume() and update Ui accordingly. Hope this helps.

system.exit(0) returned to the previous screen not closing the entire app on single click

I made three .xml files before the activity_main.xml and set a timer of 5 sec one by one for each xml file by using thread.So it takes 15 sec to reach to the main activity.
I have a problem in my EXIT button I use
system.exit(0); //behaving similar as finish()
but it returns me to the previous xml file not from the entire app.
I want to exit from entire app in a single click.
In your Manifest.xml, you should add android:noHistory="true" in your <activity> tags.
Additionally, you should not call system.exit(0), but instead just use finish().
By doing this, the activities will not be added to the back stack, and therefore, pressing the exit button (or the back button) will let the user exit the app.
Try Like this
moveTaskToBack(true);
For reference moveTaskToBack

Maintain Single instance of an activity

i have button in my first activity called Start.
Now when i click on this button it takes 1 to 2 seconds to load the next activity, now at that time the user clicks on the start button multiple times so what happens is that the next activity will open multiple times.
How to overcome this? Is there any way that even if the user clicks on the Start button multiple times open the activity only once.
Your Options:
On click, disable the button and display a ProgressDialog to the user.
Use the Intent flag FLAG_ACTIVITY_SINGLE_TOP to ensure only one activity is maintained on the stack. Documentation
Use the qualifer launchMode=singleInstance in your AndroidManifest.xml so only one instance of your Activity is allowed at a time. Documentation
I would recommend the first, because it can show the user your application is still working even if it takes a few seconds to do the necessary processing to begin your Activity.
You can put the launch mode of your 2nd activity as "Single Instance" in your manifest file.
Don't use anything like a launchMode or Intent flags. They are used for different purposes.
Description here
What you have to do is:
Show a progress dialog to clearly show the user that an
action(calling 2nd Activity) is in progress. This was user will not
try to click the button multiple times
Simply disable the button's click listener after 1st click. This is not
recommended because user might not be able to know whether he/she
clicked the button. Also this is the case where user tends to click
the button multiple times.

Resuming an activity

Hey guys I have this activity flow on my game. Start page>List of stages(from stages 1-10)>questions. If the user press the start button on the start page he will go to the list of stages, from there the only button that is enabled is stage 1 then the rest are in disable mode. In stage 1 there are 5 questions and after the user finish answering them correctly, the user will be directed back to the list of stages in which stage 2 is already unlocked as well as stage 1(stage 1 is enabled in default). Now what I want to happen is when the user exits the application using home button or back button then the user open the application again, after pressing the start button from start page he will be directed to the list of stages in which the stage 2 is still unlocked or any stages the user last finished.
As I don't understand fully your questions I have two propositions:
Save stage info in onPause or onStop and then retrieve it in onCreate method (http://developer.android.com/guide/components/activities.html#Lifecycle), or
Save everything in onStop in SharedPreferneces and retrieve when needed. I suppose this option is better.

Categories

Resources