Create Full Screen Activity on Android - Add Splash Screen to Existing Android App

Okay, We are going to talk about Two things today, First We will talk about creating full screen activity, that means when we are on that particular activity, Toolbar,Navigation are hidden from the user. 
Second, We will use this full screen activity to create Splash Screen for our android app and use that in our existing android project in android studio. 

So lets start with first one, Creating Full Screen Activity on Android studio. Actually, Android provide full screen activity and you can directly create this activity from android studio but it comes with lots of extra codes that is not really needed and only increase overhead of the app. So, in this post i will take that code and i will try to simplify to extract only code that is required for us.

Open Android Studio and create new Activity (in this case our activity name is SPLASH)on your existing project (or create new project), Select this activity as Launcher Activity, so that it will be displayed at the beginning. if You have existing project than you need to modify AndroidManifest.xml file.

Go to your Project Manifest File, You will see below code in two places so Remove this code from Activity other than your recently created Splash Activity.

Now In activity_splash.xml Add one TextView or ImageView , This Widgets will be displayed when the app is loaded for the first time. Now will create new View in our file and make it Full screen activity. We need to apply various Flags in this View to make it full screen.

Our Final activity_splash.xml looks like this, with one ImageView and one Progressbar,

Lets look at the File here, Look at the above code of file, We have created a new View using, ImageView specified in the xml file but you can use any Text or Image Widget.

Then using mContentView.setSystemUiVisibility, we have set various system flags to hide the Toolbar, Navigation bar etc.

Now, When the Full Screen activity is loaded in the devices we need to send user to other activity after sometime, at least thats the case in our app, since we are using this activity as our app's splash screen and second topic of this blog post. 

So, we need something that redirect our app user to other activity after some time, for that i have used hander in our app with PostDelayed method of hander class,
This allows us to specify the time, after which new activity can be loaded.

in the given class above the new Activity is loaded using Intent After 1000ms or 1 sec.  
Now our app has the Splashscreen, which will be displayed for 1 second and Main activity will be loaded. 

Got Confused with the process , Subscribe to our Youtube channel and I have prepared special video for this topic where i will demonstrate exact same this i talk about in this blog. 

Create Full Screen Activity on Android - Add Splash Screen to Existing Android App

No comments

Powered by Blogger.