Android Change Activity By Intent

Example:

                                    
                                        // activity_change_by_intent_example.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".ChangeActivityByIntentExample"
        android:padding="16dp"
        android:gravity="center"
        android:orientation="vertical"
        android:background="@color/colorAccent"
        >
   
       <Button
           android:id="@+id/second"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="Second Activity"
           android:textColor="@color/colorWhite"
           android:background="@color/colorOrange"/>
   
</LinearLayout>

// activity_second.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        tools:context=".SecondActivity"
        android:padding="16dp"
        android:gravity="center"
        android:orientation="vertical"
        android:background="@color/colorBrown"    >
   
           <Button
               android:id="@+id/first"
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:text="First Activity"
               android:textColor="@color/colorWhite"
               android:background="@color/colorAccent"/>
   
</LinearLayout>
                                    
                                  

Output