0% found this document useful (0 votes)
26 views3 pages

LAB 15 Implicit Intent

Uploaded by

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

LAB 15 Implicit Intent

Uploaded by

mca231419ics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: Aman Verma MET – Institute of Computer Science

Roll No:1266

EXPERIMENT 15
IMPLICIT INTENT
Aim: To design an application using implicit intent.
Assignment
1. Design an application to perform the following:
On click of the button, the application should redirect to a specified webpage.

Code:-

activity_Main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity">

<TextView
android:id="@+id/head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Implicit Intent"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:textSize="30dp"
android:layout_centerHorizontal="true"
android:textColor="#f05f21"
android:textStyle="bold"
></TextView>
<EditText

android:id="@+id/txturl"
android:layout_width="match_parent"
android:layout_height="49dp"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:hint="Enter URL"
android:textSize="20dp"
android:layout_below="@+id/head"
android:layout_margin="15dp"
android:textStyle="bold"
/>

<Button
android:id="@+id/btnsub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginStart="130dp"
android:layout_marginTop="155dp"
android:background="#167cd6"
android:text="Submit"
android:textColor="#fff"
Name: Aman Verma MET – Institute of Computer Science
Roll No:1266
android:textStyle="bold" />

</RelativeLayout>

MainActivity.java
package com.example.mcamock.implicitintent;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

Button save;
EditText edit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
save=findViewById(R.id.btnsub);
edit=findViewById(R.id.txturl);

save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String url = edit.getText().toString();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
}
});
}
}

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mcamock.implicitintent">

<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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


</intent-filter>
</activity>
</application>

</manifest>
Name: Aman Verma MET – Institute of Computer Science
Roll No:1266

Output:-

You might also like