Java Code Examples for app.akexorcist.bluetotohspp.library.BluetoothState#REQUEST_CONNECT_DEVICE

The following examples show how to use app.akexorcist.bluetotohspp.library.BluetoothState#REQUEST_CONNECT_DEVICE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From Chorus-RF-Laptimer with MIT License 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
        if (resultCode == Activity.RESULT_OK) {
            bt.connect(data);
            useBT();
        }
    } else if (requestCode == BluetoothState.REQUEST_ENABLE_BT) {
        if (resultCode == Activity.RESULT_OK) {
            bt.runService();
        } else {
            Toast.makeText(getApplicationContext()
                    , "Bluetooth was not enabled."
                    , Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}
 
Example 2
Source File: SimpleActivity.java    From BluetoothSPPLibrary with Apache License 2.0 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
	if(resultCode == Activity.RESULT_OK)
              bt.connect(data);
} else if(requestCode == BluetoothState.REQUEST_ENABLE_BT) {
          if(resultCode == Activity.RESULT_OK) {
              bt.setupService();
              bt.startService(BluetoothState.DEVICE_ANDROID);
              setup();
          } else {
              Toast.makeText(getApplicationContext()
              		, "Bluetooth was not enabled."
              		, Toast.LENGTH_SHORT).show();
              finish();
          }
      }
  }
 
Example 3
Source File: TerminalActivity.java    From BluetoothSPPLibrary with Apache License 2.0 6 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
        if(resultCode == Activity.RESULT_OK)
            bt.connect(data);
    } else if(requestCode == BluetoothState.REQUEST_ENABLE_BT) {
        if(resultCode == Activity.RESULT_OK) {
            bt.setupService();
            bt.startService(BluetoothState.DEVICE_ANDROID);
            setup();
        } else {
            Toast.makeText(getApplicationContext()
                    , "Bluetooth was not enabled."
                    , Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}
 
Example 4
Source File: MainActivity.java    From Droid2JoyStick with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
        if (resultCode == Activity.RESULT_OK) {
            BluetoothManager.getInstance().connect(data);
        }
    } else if (requestCode == BluetoothState.REQUEST_ENABLE_BT) {
        if (resultCode == Activity.RESULT_OK) {
            BluetoothManager.getInstance().setupService();
            BluetoothManager.getInstance().startService();
        } else {
            // Do something if user doesn't choose any device (Pressed back)
        }
    }
}
 
Example 5
Source File: AutoConnectActivity.java    From BluetoothSPPLibrary with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
        if(resultCode == Activity.RESULT_OK)
            bt.connect(data);
    } else if(requestCode == BluetoothState.REQUEST_ENABLE_BT) {
        if(resultCode == Activity.RESULT_OK) {
            bt.setupService();
        } else {
            Toast.makeText(getApplicationContext()
                    , "Bluetooth was not enabled."
                    , Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}
 
Example 6
Source File: ListenerActivity.java    From BluetoothSPPLibrary with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
        if(resultCode == Activity.RESULT_OK)
            bt.connect(data);
    } else if(requestCode == BluetoothState.REQUEST_ENABLE_BT) {
        if(resultCode == Activity.RESULT_OK) {
            bt.setupService();
        } else {
            Toast.makeText(getApplicationContext()
                    , "Bluetooth was not enabled."
                    , Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}
 
Example 7
Source File: DeviceListActivity.java    From BluetoothSPPLibrary with Apache License 2.0 5 votes vote down vote up
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == BluetoothState.REQUEST_CONNECT_DEVICE) {
        if(resultCode == Activity.RESULT_OK)
            bt.connect(data);
    } else if(requestCode == BluetoothState.REQUEST_ENABLE_BT) {
        if(resultCode == Activity.RESULT_OK) {
            bt.setupService();
        } else {
            Toast.makeText(getApplicationContext()
                    , "Bluetooth was not enabled."
                    , Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}