Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
By: Eliav Menachi Services are components that run in the background, without a user interface Android supports two types of services:. Local service: not accessible from other applications running on the device Remote service: accessible from other applications in addition to the application hosting the service Started via Context.startService() Runs until: Context.stopService() stopSelf() See SimpleService example Service that can be consumed by other processes via Remote Procedure Call (RPC) Android Interface Definition Language (AIDL): define the interface that will be exposed to clients To build a remote service, you do the following: 1. Write an AIDL file that defines your interface to clients 2. Add the AIDL file to your Eclipse project generate a Java interface from the AIDL file 3. Implement the service and return the interface from the onBind() method 4. Add the service configuration to your AndroidManifest.xml AIDL is a simple syntax that lets you declare an interface with one or more methods The parameters and return values can be of any type, even other AIDL-generated interfaces you must import all non-built-in types, even if they are defined in the same package as your interface Data types that AIDL can support: Primitive types (int, boolean…) String List - the other side will receive an ArrayList Map - the other side will receive a HashMap CharSequence Other AIDL-generated interfaces Custom classes that implement the Parcelable protocol Add the AIDL file to your Eclipse project Eclipse will automatically call the AIDL compiler and will generate the Java interface from the AIDL file Write a class that extends android.app.Service Implement: Implement the interface method Implement the onBind() method Add the service configuration to your AndroidManifest.xml <service android:name=".AIDLServiceImpl"> <intent-filter> <action android:name="bgu.eliav.AIDLServiceInterface" /> </intent-filter> </service> copy the AIDL file to the client project AIDL compiler creates the interface Extends the ServiceConnection get a reference to the service call the bindService()