Pass data from one activity to another using Intent in Android

In last tutorial we have seen how Move from one activity to another in Android. Now in this example we have to pass some data using Intent at the same time of switching activity.

I have create project for move one activity to another in last tutorial and now directly use this code. ¬†Let’s we pass user’s name from one activity to another. So we pass name from MainActivity.

Our both layout xml file same as before tutorial.

Using putExtra(key,value); we can pass data with key parameter.

Our SecondActivity.java is

Using getIntent() we will able to get app data send from first activity. Here hasExtra(key) is for check given key is passed or not. Its possibility to get null if some wrong key parameter entered. So now run project.

our output look like this.

android-pass-data-using-intent-skynils

Download Project.

downlod

Now see how to make Splash Screen in Android.