开发者

Bluetooth connection in next activity

i set up a bluetooth connection to a device in my mainactivity - that works.

now i wanna use the socket of the connected device i开发者_Go百科n a second activity.

how can i transfer it? getExtra wont work :/

Thanks, prexx


You should use Local Bounded Service. See more about them here: Bounded Services.

The idea is that Service will open and manage bluetooth connection, while Activities will bind to this service and get bluetooth socket via interface that extends IBinder. This way lifecycle of Activity will not interfere with lifecycle of bluetooth socket, plus you can share you socket with as many activities as you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜