Skip to content Skip to sidebar Skip to footer

Android Background Task And Lifecycle

I'm currently working on an app that connects to a bluetooth device and receives a message every .25 seconds, then displays that data on screen. The user will also be able to arbit

Solution 1:

Should I instead be looking at a service for my BT connection and logging, and then somehow get a feed from the service to display on the UI?

Yes you should. I think this is a good approach. You should run your thread the logs data in a service, and put the data that needs to be passed to the main UI or activity in a sharedpreference which will give ANY activity access to the information.

I think this would be the best way to go about doing this.

OR

You could use the method provided by alex.veprik

Solution 2:

You can prevent your activity from re-creating upon config changes. Just modify the manifest file:

<activityandroid:name=".MyActivity"android:configChanges="keyboard|keyboardHidden|orientation" />

Post a Comment for "Android Background Task And Lifecycle"