Null object sending BluetoothDevice to Service
I have this intent:
Intent serviceIntent = new Intent(getApplicationContext(), Servicio.class);
serviceIntent.putExtra(MainActivity.EXTRA_BT_DEVICE, btDevice);
getApplicationContext().startService(serviceIntent);
but for some reason, in the service with this code:
btDevice = (BluetoothDevice) params.getExtras().get(MainActivity.EXTRA_BT_DEVICE);//btDevice = getParcelableExtra(EXTRA_BT_DEVICE)
it says the intent is null but it isn't null on the activity
Intent serviceIntent = new Intent(getApplicationContext(), Servicio.class);
serviceIntent.putExtra(MainActivity.EXTRA_BT_DEVICE, btDevice);
getApplicationContext().startService(serviceIntent);
but for some reason, in the service with this code:
btDevice = (BluetoothDevice) params.getExtras().get(MainActivity.EXTRA_BT_DEVICE);//btDevice = getParcelableExtra(EXTRA_BT_DEVICE)
it says the intent is null but it isn't null on the activity
This discussion has been closed.
Comments
params.hasExtra(EXTRA_BT_DEVICE)
?