我有一個複選框可以創建一個藍牙連接。問題是,當藍牙許可請求對話框出現,我選擇「否」,複選框仍然保持checked.How我可以從這個活動獲取請求代碼,並把複選框關閉,如果我得到RESULT_CANCELED?如何從活動中獲取結果代碼?
CheckBox turnBtOnOff=(CheckBox)findViewById(R.id.checkBox1);
turnBtOnOff.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if (isChecked)
{
if(!mBluetoothAdapter.isEnabled())
{
Intent enableBtIntent=new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
//myAddress=mBluetoothAdapter.getAddress();
//Toast.makeText(getBaseContext(), myAddress, Toast.LENGTH_SHORT).show();
}
}
else
{
if(mBluetoothAdapter.isEnabled())
{
mBluetoothAdapter.disable();
}
}
}
});