Here is basically my code:
private Dialog mDialog;
private BluetoothAdapter mBluetoothAdapter;
...
private void onCreate(Bundle savedInstanceState) {
...
enabltBTButton = getMyButton();
enableBtButton.setOnClickListener(this.enableBT);
...
}
...
public View.OnClickListener enableBT = (new View.OnClickListener() {
public void onClick(View view) {
mDialog.hide();
mBluetoothAdapter.enable();
Toast.makeText(Main.this, "Bluetooth enabled", Toast.LENGTH_LONG).show();
return;
}
});
The problem: when I click the button nothing happens! I am positive that enableBTButton is referring to the correct object, but my guess is that this has something to do with my referencing mDialog and mBluetoothAdapter, both of which are declared outside of the inner onClick function.
What is an alternative solution to this?
Rather then keep fumbling with what I had, I decided that to use an AlertDialog, which seems to get the job done quite well. Thank you everyone for your solutions.