Practical 9.1
Practical 9.1
xml
<TextView
android:id="@+id/tvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bluetooth Status: Unknown"
android:textSize="20sp"
android:textStyle="bold"
android:paddingBottom="20dp"/>
<ToggleButton
android:id="@+id/toggleBluetooth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOn="Bluetooth ON"
android:textOff="Bluetooth OFF"/>
</LinearLayout>
9.1 AndroidManifest.xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
9.1 MainActivity.java
package com.example.practical7;
import android.bluetooth.BluetoothAdapter;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.ToggleButton;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Initialize views
toggleBluetooth = findViewById(R.id.toggleBluetooth);
tvStatus = findViewById(R.id.tvStatus);
9.1 Output