Changes

Jump to: navigation, search

Android 6 Remote Bound Services – A Worked Example

15 bytes removed, 07:50, 28 January 2016
m
Text replacement - "<google>BUY_ANDROID_STUDIO6</google>" to "<htmlet>androidstudio_a6</htmlet>"
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
</RelativeLayout>
</pre>
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
== Implementing the Remote Bound Service ==
The first line of the above code fragment creates a new instance of our handler class and passes it through to the constructor of a new Messenger object. Within the onBind() method, the getBinder() method of the messenger object is called to return the messenger’s IBinder object.
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
== Configuring a Remote Service in the Manifest File ==
}
</pre>
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>
Next, some code needs to be added to bind to the remote service. This involves creating an intent that matches the intent filter for the service as declared in the manifest file and then making a call to the bindService() method, providing the intent and a reference to the ServiceConnection instance as arguments. For the purposes of this example, this code will be implemented in the activity’s onCreate() method:
<googlehtmlet>BUY_ANDROID_STUDIO6androidstudio_a6</googlehtmlet>

Navigation menu