i set up a bluetooth connection to a device in my mainactivity – that works.
now i wanna use the socket of the connected device in a second activity.
how can i transfer it? getExtra wont work :/
Thanks,
prexx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.