Design an Android application that deploys layouts, widgets, styles, Intents or Fragments to perform a particular function (e.g. Phone App, Calendar App, Shopping App, etc.). The Android application MUST follow the Google layout rules. Java and Android studio are the required programming language and integrated development environment respectively
//AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.narendra.intentexample">
<uses-permission android:name="android.permission.CALL_PHONE" />
<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>
//strings.xml
<resources>
<string name="app_name">Intent Example</string>
<string name="calender">Calender</string>
<string name="phone">Dialer</string>
</resources>
//activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="com.example.narendra.intentexample.MainActivity">
<Button
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/phone"
android:layout_marginLeft="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
android:onClick="launchDialer"
/>
<Button
android:id="@+id/calender"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/calender"
app:layout_constraintLeft_toRightOf="@+id/phone"
android:layout_marginLeft="16dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="16dp"
android:onClick="launchCalender"
/>
</android.support.constraint.ConstraintLayout>
//MainActivity.java
package com.example.narendra.intentexample;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import java.util.List;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void launchDialer(View view)
{
Intent phoenIntent = new Intent(Intent.ACTION_DIAL);
startActivity(phoenIntent);
}
public void launchCalender(View view) {
PackageManager packmngr = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = packmngr.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
ResolveInfo Resolvebest = null;
for (final ResolveInfo info : list) {
if (info.activityInfo.packageName.endsWith(".calendar"))
Resolvebest = info;
}
if (Resolvebest != null) {
intent.setClassName(Resolvebest.activityInfo.packageName,
Resolvebest.activityInfo.name);
startActivity(intent);
}
}
}
//Output:-->

Design an Android application that deploys layouts, widgets, styles, Intents or Fragments to perform a particular...