How to start a new Activity in Android

As we create first app of android name “AddingTwoNumbers” let’s continue with this app and add more feature e:g When app start/open there is a image as a background and after 5second the activity change.

This is the link of first app! https://shinersoft.net/blog/add-two-numbers-android/

Let’s start…

Step# 01

Open a AddingTwoNumbers project there already one activity present name activity_two_numbers.XML

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

Now create another activity file for splash screen right click on layout then new->file and give the name of file name splash.XML remember the file name must start with lower case letter.

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

 

 

Step# 02

Now add image in drawable-Hopi folder which is used to splash screen background. Download any image and named it Splash background or whatever.

How to start a new Activity in Android

 

 

 

 

 

 

 

Step# 03

Now refresh the folder if you don’t able to see the splash image in folder right click and then refresh.

Now right code for splash.XML

How to start a new Activity in Android

 

 

 

 

 

 

 

 

Step# 04

Now add class in src folder right click on com.example.addingtwonumbers and then click New->Class

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

Now right click between the brackets then go to source->override/Implement Methods like this

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After this you can see another window select on create then ok.

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

Now you can see Splash.java in this condition.

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

SaveInstanceState this is the variable here you write your own name or any other name just like this.

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

Now set the content view and timer of splash screen in next screen shot by using try catch and finally.

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

 

Step# 05

Open androidmanifest.xml to decide which activity is to open first set the activity tag under the application tag

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

 

 

Step# 06(Result)

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

 

After 5 second you can see this activity on the screen.

How to start a new Activity in Android

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Another Feature discuss is in next tutorial thanks