Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the MainActivity and a BluetoothActivity. The following code is from BluetoothActivity:

Java
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);
 }

AndroidStudio tells me the function onActivityResult is never used.
When I test the App on my Phone, I get the BluetoothRequest and can Choose my answer but afterwards the ContentView shows nothing.

Somebody knows how to get the Result in this BluethoothActivity?
Posted
Updated 16-Oct-15 7:28am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900