Mad Assignment 10
Mad Assignment 10
Mad Assignment 10
Name:Aniket Joshi
Roll No:09
DIV: N
Prn: 12310510
<!--Relative Layout-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="168dp"
android:layout_marginTop="157dp"
android:layout_marginEnd="155dp"
android:layout_marginBottom="526dp"
android:padding="5dp"
</RelativeLayout>
JAVA:
package com.example.callingassignment;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
EditText edittext;
Button button;
@SuppressLint("MissingInflatedId")
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.button);
edittext = findViewById(R.id.editText);
button.setOnClickListener(arg -> {
String
phone_intent.setData(Uri.parse("tel:" + phone_number));
// start Intent
startActivity(phone_intent);
});}
OUTPUT: