0

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?

ErstwhileIII
  • 4,829
  • 2
  • 23
  • 37
gkapellmann
  • 313
  • 3
  • 19

1 Answers1

0

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.

straya
  • 5,002
  • 1
  • 28
  • 35
  • What is the difference betweeen making it a service or registering it as a receiver? – gkapellmann Oct 13 '14 at 01:41
  • 1
    In a Service, your BroadcastReceiver could have access to anything else in the Service, for example bound Activities. Registered in Manifest, the BroadcastReceiver is more stand-alone. – straya Oct 13 '14 at 07:15