private Context context; private TextView textView; private final int REQUEST_ENABLE_BT = 1; private BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter() public Bluetooth(Context context){ //constructor this.context=context; textView = new TextView(this.context); } public void bluetoothActivate(){ if(!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); ((Activity) context).startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } } protected void onActivityResult(int requestCode, int resultCode, Intent data){ textView.setText(resultCode); ((Activity) context).setContentView(textView); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)