Intent Method

 MainActivity -


package com.example.intent;


import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;


public class MainActivity extends AppCompatActivity {


    Button button;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        button=findViewById(R.id.nextpage);


        button.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View v) {

                Intent intent=new Intent(MainActivity.this,Home_Activity.class);

                startActivity(intent);

            }

        });



    }

}


----------------------------------------------------------------------------------------------------------------------------


HomeActivity -



package com.example.intent;


import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle;


public class Home_Activity extends AppCompatActivity {


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_home_);

    }

}


------------------------------------------------------------------------------------------------------------------------------


activity_main -


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:background="#bac"

    android:gravity="center"

    tools:context=".MainActivity">


    <TextView

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Welcome Activity"

        app:layout_constraintBottom_toBottomOf="parent"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintTop_toTopOf="parent"

        android:textSize="35sp"/>


    <Button

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:id="@+id/nextpage"

        android:layout_marginTop="20dp"

        android:text="Enter"/>


</LinearLayout>


-----------------------------------------------------------------------------------------------------------------------


AndroidManifest -



<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.intent">


    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"

        android:label="@string/app_name"

        android:roundIcon="@mipmap/ic_launcher_round"

        android:supportsRtl="true"

        android:theme="@style/AppTheme">

        <activity android:name=".Home_Activity"></activity>

        <activity android:name=".MainActivity">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest>

Comments

Popular posts from this blog

Generate Signing Release keystore

πŸš€ COMPLETE CI/CD FROM SCRATCH

Camera Application