java - How to send string from an activity to a thread called in main activity [ANDROID] -


i'm developing bluetooth chat android. problem:

my main activity starts thread manage bt connection, , starts new activity b. must know way send string continually activity b thread called in main activity a. how can it?

if directly start thread, there no way of accessing thread activity , may cause memory leaks.

your best option have separate service manage bluetooth connection.

you can have separate service , initiate tread form service (service runs in main thread).

and have careful starting , stopping of service.

there 2 ways start service,

you can start service or can bind sstrong textervice.

in case have start service in can bind service form both activity , activity b, or can start service in activity , bind activity b.

but thing have careful when stop service. otherwise have memory leaks.

once service , running can communicate from-to activity. , can pass ever information tread running in service component.

you can read on in processes-and-threads , services


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -