Bluetooth_PairedDevices
Bluetooth_PairedDevices
xml
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List Paired Devices"
android:onClick="list" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paired devices:"/>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
MainActivity.java
import android.app.Activity;
import android.widget.Button;
import android.widget.ListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b1 = findViewById(R.id.button1);
b1.setOnClickListener(v -> listPairedDevices());
}
listView.setAdapter(new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1, deviceNames));
Toast.makeText(this, "Showing Paired Devices", Toast.LENGTH_SHORT).show();
}
}
AndroidManifest.xml