Assignment 6 MC 007
Assignment 6 MC 007
Assignment 6 MC 007
Roll No: 07
Assignment - 6
Use implicit intent to show the website, to send the text to messenger and send text to
another application.
Code:
App1:
MainActivity.java:
package com.example.p6;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
//Send SMS
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
str = ed1.getText().toString();
Intent sms = new Intent();
sms.setAction(Intent.ACTION_SEND);
sms.putExtra(Intent.EXTRA_TEXT,str);
sms.setType("text/plain");
startActivity(sms);
Subject: MCAL34 Mobile Computing Lab Academic Year
First Half 2023_24
SIES College of Management Studies SYMCA (Revised), Sem III,
Roll No: 07
}
});
//View Webpage
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent web = new Intent(Intent.ACTION_VIEW);
web.setData(Uri.parse("https://www.siescoms.edu.in"));
startActivity(web);
}
});
App2:
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.P6_2"
Subject: MCAL34 Mobile Computing Lab Academic Year
First Half 2023_24
SIES College of Management Studies SYMCA (Revised), Sem III,
Roll No: 07
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
</application>
</manifest>
act2.java:
package com.example.p6_2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv1;
tv1= findViewById(R.id.tv1);
Intent in = getIntent();
String sharedText = in.getStringExtra(Intent.EXTRA_TEXT);
tv1.setText(sharedText);
}
}
Subject: MCAL34 Mobile Computing Lab Academic Year
First Half 2023_24
SIES College of Management Studies SYMCA (Revised), Sem III,
Roll No: 07
Output: