0% found this document useful (0 votes)
84 views12 pages

MAD18: Implicit and Explicit Intents

Uploaded by

kamble04ay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views12 pages

MAD18: Implicit and Explicit Intents

Uploaded by

kamble04ay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Subject: MAD[22617] Practical no: 18

Performed by: Pratik Bais Roll no: 51

• Implicit Intent

activity_main.xml

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


<RelativeLayout
xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/urlText"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:ems="10" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnNavigate"
android:layout_below="@+id/urlText"
android:text="Navigate"
android:layout_centerHorizontal="true" />
</RelativeLayout>

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
EditText editText = (EditText)findViewById([Link]);
Button btn = (Button) findViewById([Link]);
[Link](new [Link]() {
1|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

@Override
public void onClick(View view) {
String url = [Link]().toString();
Intent intent = new Intent(Intent.ACTION_VIEW, [Link](url));
startActivity(intent);
}
});
}
}

Output

• Explicit Intent

2|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="[Link]
android:orientation="vertical">
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Home"
android:textSize="30dp"
android:textStyle="bold"
android:textColor="#2C2496"

app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/oppo"
android:layout_margin="10dp"></ImageView>

<ImageView
android:layout_width="wrap_content"
android:layout_height="262dp"
android:layout_margin="10dp"
android:src="@drawable/realme"></ImageView>
</LinearLayout>

3|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="148dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"

android:layout_marginLeft="80dp"
android:text="OPPO"
android:textSize="20dp"
android:textStyle="bold"></TextView>
<TextView
android:layout_width="148dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"

android:layout_marginLeft="50dp"
android:text="Realme"
android:textSize="20dp"
android:textStyle="bold"></TextView>

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/samsung_tab"
android:layout_margin="10dp"></ImageView>

<ImageView
android:layout_width="wrap_content"
android:layout_height="232dp"
android:layout_margin="10dp"
android:src="@drawable/lenovo_laptop"></ImageView>

</LinearLayout>

4|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<TextView
android:layout_width="148dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"

android:layout_marginLeft="80dp"
android:text="Samsung"
android:textSize="20dp"
android:textStyle="bold"></TextView>
<TextView
android:layout_width="148dp"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"

android:layout_marginLeft="50dp"
android:text="Lenovo"
android:textSize="20dp"
android:textStyle="bold"></TextView>

</LinearLayout>
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="170dp"
android:text="Next"
android:textSize="25dp"
android:textStyle="bold"
></Button>

</LinearLayout>
</ScrollView>

[Link]
package [Link];

import [Link];

5|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {


Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
btn=findViewById([Link].btn1);
[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent intent=new Intent([Link],Contect_Us.class);
startActivity(intent);
}
});
}
}

activity_contect_us.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Contect_Us"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Contect Us"
android:textSize="40dp"
android:textStyle="bold"
android:textColor="#2C2496"

app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

6|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_marginLeft="100dp"
android:text="Contect number"
android:textSize="25dp"
android:textStyle="bold"></TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="100dp"
android:text="1289563424"
android:textSize="25dp"
android:textStyle="bold"></TextView>

<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginLeft="150dp"
android:text="Next"
android:textSize="25dp"
android:textStyle="bold"
></Button>
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginLeft="130dp"
android:text="Previous"
android:textSize="25dp"
android:textStyle="bold"
></Button>

</LinearLayout>
Contect_Us.java
package [Link];

import [Link];

import [Link];

7|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

import [Link];
import [Link];
import [Link];

public class Contect_Us extends AppCompatActivity {


Button btn,btn1;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_contect_us);
btn=findViewById([Link].btn2);
btn1=findViewById([Link].btn3);
[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent intent=new Intent(Contect_Us.this,About_us.class);
startActivity(intent);
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent intent=new Intent(Contect_Us.this,[Link]);
startActivity(intent);
}
});
}
}
activity_about_us.xml

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


<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Contect_Us"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="About Us"
android:textSize="40dp"
android:textStyle="bold"

8|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

android:textColor="#2C2496"

app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_marginLeft="100dp"
android:text="Name: ABC"
android:textSize="25dp"
android:textStyle="bold"></TextView>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginLeft="100dp"
android:text="Phone No: 1289563424"
android:textSize="25dp"
android:textStyle="bold"></TextView>

<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginLeft="110dp"
android:text="Previous"
android:textSize="25dp"
android:textStyle="bold"
></Button>

</LinearLayout>

About_us.java
package [Link];

import [Link];

9|Page
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

import [Link];
import [Link];
import [Link];
import [Link];

public class About_us extends AppCompatActivity {


Button previous;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_about_us);

previous=findViewById([Link].btn5);

[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent intent=new Intent(About_us.this,Contect_Us.class);
startActivity(intent);
}

});

}
}

10 | P a g e
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

Output

11 | P a g e
Subject: MAD[22617] Practical no: 18
Performed by: Pratik Bais Roll no: 51

12 | P a g e

You might also like