Android: How to load the main activity while on the splash screen - android

I got a splash screen activity and a main activity with webview. It takes 4 to 5 seconds after loading of the main activity which is after the Splash screen, I wanted solution for start loading the main activity parallelly while in the splash screen
Thank you in advance 😊

Within splash activity you should create background service to finish time consuming jobs,
then transfer obtained data to main activity using bundle.Thus your main activity will load faster.
There are many ways to complete background tasks,please ref this doc.

Have loader on your MainActivity, once everything is loaded, just set loader's visibility to GONE.
No need to use SplashScreen in this case

Related

Create splash screen on android with GIF is freeze when start main activity

I'm trying to create SplashScreenActivity and show WebView with GIF file before call:
StartActivity(typeof(MainActivity))
I found that the animation was stopped when StartActivity is called.
I also try to use AnimationDrawable to play the animation as a frame instead. But the result was the same: The animation will be stopped when StartActivity is called.
I think these happened because UIThread is blocked when call StartActivity.
Is there anyway to use animation as splash screen that will not be blocked while MainActivity is call to start Xamarin?
Thank you in advance.
You can do it in multiple ways , the easiest way to set gif in your splash screen is that ,just create custom views and load .gif image like this
Call Task.Delay(2000).Wait(); in SplashScreenActivity before you call start main activity for duration you want the animation to play

Splash screen between two activities

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 :-)

Android Splash Screen Bug

I display a splash screen for about 3 seconds before my first Activity is called. Splash Screen is also an Activity, after 3 seconds it finish()es and starts FirstActivity.
Also I have set screen rotation of splash Activity to portrait view.
Now when I test my app it works fine, but during those 3 seconds of splash screen if i change screen rotation, my First Activity is called two times.
Is there any way / code snippet that could help me open my First Activity only once, despite screen rotations when Splash Screen Activity is at foreground. ? Thanks for helping :)
It's not really a bug. When you change orientation the current activity is created again, hence why your SplashActivity is called twice.
I wrote a blog post about handling orientation changes manually; http://c0deattack.wordpress.com/2010/12/25/dealing-with-screen-orientation-changes-manually/
I also had this 'bug'. Here it describes how I solved it: Activity reloads when orientation changes in Android
I think your thread of splash screen gets call again one more time.
So simply set a flag to check screen rotated or not. If yes than do not call this thread again. eg.
boolean yourScreenRotationFlag=false;
if(!yourScreenRotationFlag)
{
// your splash thread code
}
and on rotation of screen set this flag to true.
you can solve it by add this xml attribute to the Splash Activity in the Mainfest
android:configChanges="orientation|keyboardHidden|screenSize"
it prevent your activity from Re-create when orientation occured

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.

Download data and update MapView

I am looking for some guidance and hopefully someone can tell me the proper way to implement this scenario. In my app I am going to show a splash screen on startup and immediately start downloading some data from internet. When splash screen is finished, after about three seconds, the mapview should be shown. When the downloading of data is finished, after about one to ten seconds, the mapview should be updated with points of interest relating to the downloaded data. How do I best implement this in Android. Of course I first have an activity for the splash screen and another mapactivity for the mapview. But what do I use to download the data and when it is finished notify the mapactivity to update the mapview? Do I use an asynctask?
Best regards
P
SplashScreen does not need to be a separate Activity since it does not handle user events.
Just put splash screen and mapview inside one activity. Use FrameLayout to position splash screen on top of mapview.
Start loading data when Activity starts (onCreate). Use AsyncTask to do network communication in the background while correctly updating view when data arrives.
Create Handler and call postDelayed() to dismiss splash screen after some time.

Categories

Resources