Search code examples
androidbluetoothgoogle-glassgoogle-gdk

Google Glass Broadcastreceiver across activities


I have an activity where I create a BroadcastReceiver and create a connection with Bluetooth to some other device. My main activity has a set of cards in a CardScrollView. The cards in this array are devices that my app finds that are able to establish connection. When I get connected to one device I am opening a new activity with another CardScrollView and other set of cards, the Bluetooth connection seems to stay but I can no longer exchange information even if I return to the main activity.

So the question is, should I register different the BroadcastReceiver? Or my aproach of the second activity is not the best one?


Solution

  • Make your BroadcastReceiver independent of your Activities, e.g. in a Service or simply in the Manifest as a separate class with an event bus mechanism.