Practical No 24
Practical No 24
Q1.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".MainActivity">
<EditText
android:id="@+id/editTextTextPersonName"
android:layout_width="162dp"
android:layout_height="48dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Atharva Butte"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bluetooth"
android:textSize="24sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn on"
android:onClick="turn_on"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="get_visib"
android:text="Get visible" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List device"
android:onClick="list_d"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn off"
android:onClick="turn_off"/>
<ListView
android:id="@+id/listV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.practical24;
import androidx.appcompat.app.AppCompatActivity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import java.util.Set;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}