I have a splash screen activity which is supposed to launch a landing activity and finish itself. When I enable activity transitions, with a simple slide animation as both enter and exit animations, I see that the splash activity finishes before the landing activity slides up completely. This causes an intermediate phase when users see the Android launcher screen.
I tried using finishAfterTransition() as suggested here, but no luck. Is this a bug in the support library? Or am I not supposed to use transitions on activities which may finish after launching a new activity?
The method overridePendingTransition() and animation parameters R.animator.fade_in, R.animator.fade_out have worked for some.
It is described here
Related
how to make activity full screen and navigate back to previous activity without any UI flicker.
full screen activity
use Theme
<activity android:name"MainActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen">
and navigate back to previous activity without any UI flicker
is mean how to make back button?
You can choose between two options
Apply new exit animation of Activity, such as fade out, scale out, .... It will reduce the lagging-effect to the eyes.
Use Fragment instead. Fragment transition is smoother than activity transition.
Try both ways and compare them to get the better options. I recommend you the second :D
Will be obliged if someone can help me with this.We were working on some android application,while designing its prototype we came across some issues.A little description of the application's prototype is as follows:
A Log in screen
a Home screen with logout at its top right
Every other activity is having a home button on top right corner.
Now going from one activity to the other in my application, I just called finished on the current activity and started the other(so there is no stack of the activities is being created) and when home button present on each activity's top corner is pressed i finish the current activity and move to the home screen.
More precisely,i can say that i am overriding every activty's onBackPressed() method
.By doing this i am not letting android to keep a stack of the activity's but by doing this I have a feeling that, I am loosing efficiency and degrading performance.Because on every backpress or home button click one activity is finished and the other is created.Hence some lag can be seen as the acivity is recreated.
Please suggest that should I continue WITH THIS or there is some other way out to handle this
Thank you for Giving your time
It is depends.
If you are giving option on each screen to to go home this approach is good.
Because if you are keep activities in stack it will be in RAM which is limited so it may create memory issue if to many activities in stack.
I would like to suggest one more thing.
As you say you have overridden onBackPressed() method in each activity.
Rather doing this there is a option you can specify parent activity in manifest tag.
So you no need to manually handle by overriding onBackPressed() method.
EG.
<activity
android:name="com.xxx.DetailActivity"
android:parentActivityName="com.xxx.src.ListActivity"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
I want to make a SplashScreen before the main activity starts. I've been carefully replicating this tutorial but there are still problems.
In my code I have an animation in SplashActivity. But my MainActivity has so many elements to initialize that the animation in SplashScreen Activity is lagging a lot.
Is there any possible way to manage this? I tried to use runOnUIThread in the onCreate method of MainActivity, but that made the problem even worse.
actually with 4.4 OS Google is asking to do away with splash screens.
You are better off putting some dummy screen -> splash screen -> main activity. Here dummy screen with no have anything in it.
Provided you want splash screen with no action bar. If you add empty action bar to splash screen you can keep as it is
splash screen -> main activity.
Time lag is due to android takes time to start activity with no action bar at the start of the application.
I just noticed a pretty large amounts of error in my code.
My app has quite a few pages (in the form of fragments) and a splash screen.
The manifest is set up to load the splash screen and then start the mainactivity class.
When the mainactivity class loads up (after the splash screen) it shows the home page of the app, thats fine, but when i load up another fragment I always just assumed that if I hit the back button on the device it would take me back to the page opened before hand but instead of that it takes me back to the splash screen and traps me there.
Any help guys?
After you launch the main activity from the splashscreen you should call finish() on the splashscreen to ensure that it will not show up again (after all, it will not be needed anymore, so why keep it alive?). Then you should override onBackPressed on your main activity and ensure that instead of calling super, and finishing the current activity, it will call your fragments adapter and change the current visible fragment.
You need to use addToBackStack functionaliy of fragmentTransaction
Take a look at docs and example
I've searched SO and found several answers to the question in general, and have tried them all and am not having success. I really don't have my head around how the back stack works, Intent flags or the finish method. Here's my setup:
On application start-up, there's a splash screen where a couple AsyncTasks run in the background and check a couple webservers for updated content. ProgressDialogs report status. When complete (via the last onPostExecute), I launch a new Activity ("Home"). This seems to reflect some of the other posts, but I think my kludge is due to Home being a TabActivity, with 4 tabs, that initially calls setCurrentTab on tab 0.
So, using the suggestions previously posted:
android:noHistory="true" on the Splash activity
calling Splash.this.finish() after it launches the Home TabActivity
setting the Home TabActivity intent flag of Intent.FLAG_ACTIVITY_CLEAR_TOP
setting the Home TabActivity intent flag of Intent.FLAG_ACTIVITY_NO_HISTORY
The users sees the splash, the TabActivity launches, the user clicks to another tab, then hits back - the application closes (not force close - just closes back to the devices home screen).
If I don't use any of those, when the user hits back after changing to another tab, they go back to the Splash screen and are stuck (I could add a button or something to take them to the Home TabActivity but that's not optimal).
The desired result is that the user sees the Splash, gets taken to the Home TabActivity, clicks another tab, then hits back, he should be taken back to the initially set tab (tab 0).
Any insight is appreciated.
TYIA
The back stack is actually officially called the activity stack - every time you start an activity, that gets pushed onto the top of the stack (unless you set one of those flags you mentioned).
This means that unless each tab in your main app is a separate activity, then the default back key behaviour will be to leave your main app activity.
You can control this by taking over the back key or by overriding the tab switching behaviour to start different activities.