Splash screen between two activities - android

I want to show a splash screen between my first and second activity. Both the activities make use of AsyncTask. First being a simple login screen retrieving data for the whole app and second loads the activity specific data. Currently, both the activities have their own ProgressDialogs which is quite naive but they were developed individually and then I wasn’t planning to put them one after the other.
I tried to implement the splash screen only replace a loading process from one activity. But, in order to place a splash screen in between them do I have to transfer all the loading process to a single activity? Which activity should contain the code for the splash screen? I basically want to replace two ProgressDialogs by a single splash screen. What should I do?

I think the simplest way would just make a transitional activity that displays a splash screen, preloads the data for the next activity, then launches the next activity.
Activity A loads Activity B which shows the splash screen while simultaneously running the AsyncTask. Once the AsyncTask completes load Activity C.
I hope I understand your question correctly :-)

Related

Start second Android activity in the background to load before bringing to front

In my Android app, I have second activity (a Unity game) that I launch from a button click. The problem is that there is a significant loading time that it needs to go through before opening up. Once I press the button I would like it to launch in the background but have the first app still open while the second one finishes loading.
Does anybody know how to do this?
Many thanks.
Based on your comments, you should first create a Loading Scene inside Unity and launch it as first scene when starting the second Activity and than inside your Loading scene start loading in the background the level you want to show. There is no way to load the Activity in the background and then show it once it's ready.
And another thing, keep in mind that Unity is loading native libraries and there is no way to open it as fast as a normal Android Activity.

How do I best control activity flow?

I am tasked with building an app that does not have a fixed screen order.
When started the app will contact a server an get a list of actions to perform.
So one launch could be
screen 1 - screen 5 - screen 7
next time
screen 3 - screen 5 - screen 9
I tested a simple app that does that; my Main activity starts the needed activity and that activity returns to the main activity, which starts the next needed activity.
In other words, all activities return to the Main activity which then determines which activity to start next.
It seems to work fine, but I have read that Activities should only be used for UI, my Main activity had no UI, it just controlled which activity happened next. So should I be using a different approach?
I am brand new to Android, but have decades of Java experience.
In case it makes a difference, I am using AS 3.0.1
Thanks
I'd suggest one activity and implementing your "screens" as fragments. This makes it really easy to code your logic for what screen comes next. You are just adding / replacing fragments and not starting and tracking result codes of activities. The business logic for each screen can still be fully encapsulated in the fragment.

Display a Dialog over 2 different activities

I have a game menu, which is one activity, and an actual game, which is another activity.
I also have a custom Dialog class that displays a "Loading..." text and a spinning wheel. (I could add code, but it's almost identical to a normal ProgressDialog. Nothing special about it).
I wish to start displaying this dialog from the menu activity (when loading), and continue its display for after the transition to the game activity - until the game finishes loading.
Is that even remotely possible? I didn't fid a way to extend a Dialog over 2 activities. It seems to be bound to one.
Is that even remotely possible?
Not as far as I know. A Dialog is a UI element and as such exists withing the 'window' of the Activity which created it. Starting a new Activity obviously means it will cover the previous one and any Dialog it's currently showing.
It seems to me there are only two simple ways of doing what you want...
Make sure that what is 'loading' your game is running in some separate place (Service etc) and progress is accessible from both Activities then simply destroy the first Dialog when the second Activity is started, create a new Dialog and have it pick up from where the first one left off (with progress, messages etc).
If your menu and main game play can be hosted by Fragments then simply swap a menu Fragment to a game Fragment within a single Activity. That way the Dialog will continue to exist without interruption.
I don't think dialog can be extended with two activities, It actually requires a activity context to run. so if activity will be destroyed it will automatically leaked.
Please post answer if you find the way.

Change default Activity dynamically

I want to be able to change which Activity is run when the user runs the application.
I know how to do this in the application's manifest file, but I would like to do it programmatically after install. The reason being, I want the user to be able to choose which screen loads when he opens the application.
How can I do this? The only way I know of seems very clunky: have an essentially empty Activity which has the MAIN intent-filter - which then reads the user's settings and transfers the user to the desired Activity. This creates a lot of mess, like the back-stack needs to be considered, and the overheads of loading one activity straight after another seems wasteful of time and resources.
You cannot change launcher activity dynamically.
As you said it is possible by saving user preferences and start desired activity each time. I have tried it and it is fast enough to not show itself. Don't remember to call finish on main activity. it will solve back stack problem.
Also you can use different fragments for different activities and decide which one should be added to main activity. It may be faster. However as I said it is fast enough to start a new activity and hide main activity because it is done in onCreate method. Don't worry about that.

Blank screen loader in android

I have problem with progress bar between two activities. When app loading form one activity to another activity I am getting blank screen for few seconds in my app due to the lazy loading images in the second activity. I want to display the progressbar in that blank screen. How can I do it?
Thanks and Regards,
Bhargav
Start your second activity and launch AsyncTask for lazy loading with ProgressDialog bounded in it.
See the example here or here, and check this question.

Categories

Resources