Android Communication between service and activity from other projects -
i've developed foreground service should handle bluetooth low energy communication between specific hw device.
this service has got activity in can set parameters manage service, anyway works activiy killed too.
the service contains bootreceiver , started device boot.
now, aim create another projects 1 or more activityes, 1 have communicate service , excange data.
i've looked aswer on net , results:
- bind , interface
it seems 1 correct 1 lot complicated , involves lot of code little data.
- broadcast receiver
broadcast receiver easy implement, if should read data bluetooth each 100ms example? don't think correct way.
which correct way of implementing communication that?
in android have several ways share data between application, it's depend on - how many data want share between applications, cyber issues, battery consumption , timing issues:
1) can use aidl in both app in order share data, please aware not able send objects, should convert data parcelable or byte-array. pros - great solutions short data.
2)sharedpreferences , use same android:shareduserid="android.uid.share" on both application - not recommended due battery consumption , timing issue, great share big data.
3)you can use client/server model , open unix socket on bot applications - pros - reliable , can secured, cons - short battery life.
4)broadcast receiver - [not recommended] due potentially timing issue.
5)using shared file @ sdcard - not recommended.
Comments
Post a Comment