Bluetooth connection in Background as a Service in Android?
I am developing an application in which Android device will be connected to a device via bluetooth and they will be exchanging certai开发者_开发百科n packets. Now, the packet communication should be running in background and user can navigate through the screens of the app. So, for this purpose using bluetooth communication running as service is proper solution or not? If not, then can someone let me know of alternative to it.
One more thing that I wanted to know is whether its a good idea to have the service as "Remote" and communicate over IPC or the Service should be running in the same process as Application.
Yes, it's a perfectly good solution. Actually, I think service components are exactly for this kind of work. Be sure to check on wake locks too, if you don't want to lose connection when the phone gets in suspended mode.
Yes, It is a perfectly good solution. You need to define Service in AndroidManifest file.
<application android:name="com.example.MyApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<service
android:name="com.example.BLEService"
android:enabled="true" />
精彩评论