0

I am trying to pass the BluetoothDevice Object that I acquired from MainActivity ,after my device and other device bonded, to my ExerciseActivity. But before i reach the exercise activity I have to cross to my RecyclerActivity where the recyclerView is there under the ExerciseAdapter. How can i pass the BluetoothDevice Object to my Exercise Activity? I tried passing thru intern like this.

if(action.equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)){
            BluetoothDevice mDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            //case 1
            if(mDevice.getBondState() == BluetoothDevice.BOND_BONDED){
                Log.d(TAG,"mBroadcastReceiver4: BOND_BONDED");

                mBTDevice = mDevice;

                Intent exerciseIntent = new Intent(MainActivity.this, RecyclerActivity.class);
                exerciseIntent.putExtra("btDevice",mBTDevice);
                startActivity(exerciseIntent);

            }

I thought the the ExerciseAdapter can still get the extra Intent because it is inside my RecyclerActivity. How can my ExerciseAdapter get the Extra Intent coming from Recycler Activity and pass it to my ExerciseActivity? Thank you for answering.

Alex Bravo
  • 1,601
  • 2
  • 24
  • 40

1 Answers1

0

ExerciseAdapter is created by you in RecyclerActivity. Just take BluetoothDevice from getIntent() and pass it as a parameter to the constructor of the adapter. Then when you start ExerciseActivity you just pass this bluetoothDevice once again.

RadekJ
  • 2,835
  • 1
  • 19
  • 25
  • thank you for the response. I already solved my problem. and this is also what i actually did. I just needed to include the BluetoothDevice object to my class Constructor since the object is inherit from may Activity. Sorry I 've read your answer late but Appreciated you buddy. – Jason Villamor Mar 10 '19 at 13:44