@Override protected void onStart() { super.onStart(); if (btService != null) { btService.registerActivity(BtGameConfigurationActivity.class); } }
@Override public void onServiceConnected(ComponentName name, IBinder service) { btService = ((BluetoothService.BtBinder) service).getService(); btService.registerActivity(BtGameConfigurationActivity.class); messageChannel = btService.getChannel(CHANNEL_ID); messageChannel.setOnMessageReceivedListener( new BluetoothService.OnMessageReceivedListener() { @Override public void process(final byte[] buffer) { BtGameConfigurationClientActivity.this.runOnUiThread( new Runnable() { @Override public void run() { long seed = fromByteArray(Arrays.copyOfRange(buffer, 0, 8)); byte color = buffer[8]; byte type = buffer[9]; Log.d(TAG, Long.toString(seed)); Intent intent = new Intent( BtGameConfigurationClientActivity.this, BtGameActivity.class) .putExtra(GameActivity.SEED, seed) .putExtra(GameActivity.GAME, (int) type) .putExtra( BtGameActivity.LOCAL_PLAYER_COLOR, color == GameConfigurationActivity.COLOR_WHITE); startActivity(intent); shouldStop = false; finish(); } }); } }); }