コード例 #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    switch (id) {
      case R.id.action_reset:
        try {
          mwBoard.getModule(Debug.class).resetDevice();
          Toast.makeText(this, R.string.message_soft_reset, Toast.LENGTH_LONG).show();
        } catch (UnsupportedModuleException e) {
          Toast.makeText(this, R.string.error_soft_reset, Toast.LENGTH_SHORT).show();
        }
        return true;
      case R.id.action_disconnect:
        mwBoard.setConnectionStateHandler(null);
        mwBoard.disconnect();
        finish();
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
コード例 #2
0
  @Override
  public void onBackPressed() {
    mwBoard.setConnectionStateHandler(null);
    mwBoard.disconnect();

    super.onBackPressed();
  }
コード例 #3
0
  @Override
  public void onDestroy() {
    super.onDestroy();

    /// < Unbind the service when the activity is destroyed
    mwBoard.setConnectionStateHandler(null);
    getApplicationContext().unbindService(this);
  }
コード例 #4
0
 @Override
 public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
   mwBoard = ((MetaWearBleService.LocalBinder) iBinder).getMetaWearBoard(btDevice);
   mwBoard.setConnectionStateHandler(connectionHandler);
 }
コード例 #5
0
 @Override
 public void resetConnectionStateHandler(long delay) {
   mwBoard.setConnectionStateHandler(connectionHandler);
   attemptReconnect(delay);
 }