Android - Shared networking between activities -


i developing application utilizes custom network protocol on tcp. several tasks within application use different activities each activity requires networking enabled (since each activity has send/receive custom packets on network). idea to

  1. at application start - create service handle networking ( read somewhere should networking in thread in service prevent anr)

  2. when new activity run, binds service. during time sends/receives data service. when activity ends, unbinds service.

i know if makes sense.

also, understand can send data service (to send on network) using aidl interface, how receive data service? polling through aidl seems way can think of - means need thread in each of activities prevent anr. surely there better way.

i appreciate , open suggestions.

actually i've been reading more , beginning @ callback methods in sample code provided here. after reading more thoroughly have better understanding of services , aidl.


Comments