java - Starting a service from a non-UI thread (Bluetooth) -


i've created distinct thread in app purposes of creating rfcomm socket communicate with. however, want actual communication done in service can persist across dumb things orientation changes.

something this:

private class grabsocket extends thread {   private bluetoothsocket socket = null;   public socketretriever(bluetoothdevice device) {     socket = device.createrfcommsockettoservicerecord(uuid);   } } 

how can pass socket service? if try within thread, service outlive thread, or die thread does?

as @submersed mentioned, can pass socket service using binder.

if try within thread, service outlive thread, or die thread does?

if start service work till explicitly call stopservice or stopself. if bind it, work till last client unbinds it. so, service's lifecycle doesn't depend on thread's lifecycle.


Comments