NOTE: Of late, I have been getting requests for very trivial problems that many of you are facing in your day-to-day work. This blog is not to solve your "project" problems - surely not a "Support" site.
I just love to share my knowledge in my spare time and would appreciate any questions or feedback on the articles and code I have shared. I also do appreciate thought-provoking questions that would lead me to write more articles and share.
But please do not put your day-to-day trivial problems here. Even if you do, you most probably would not get a response here.

Search This Blog


Thursday, 24 September 2009

Remote Service | Android Developer Tutorial (Part 9)

Services typically are required to run for a long time and hence should run in their own thread. Such services can be invoked by any number of clients who want to connect to the service, invoke a few methods on the service and finally release the service, probably to serve more clients or close down.

Here, I would like to introduce you to the concept of connecting to a remote service and the kind of support provided by the android platform for the same.

We have earlier seen how local services can be created and used. The difference between the two mainly is that the local service runs in the same process as the application that started it and hence the life of the local service is dependent on the life of the said application while remote service can run in its own process. This causes a challenge of inter-process communication. If one process wants to communicate with another process, the object that is passed between the two needs to be marshaled.

For this purpose, Android provides the AIDL (Android Interface Definition Language) tool that handles the marshaling as well as the communication.

The service has to declare a service interface in an aidl file and the AIDL tool will automatically create a java interface corresponding to the aidl file. The AIDL tool also generates a stub class that provides an abstract implementation of the service interface methods. The actual service class will have to extend this stub class to provide the real implementation of the methods exposed through the interface.

The service clients will have to invoke the onBind() method on the service to be able to connect to the service. The onBind() method returns an object of the stub class to the client. Here are the code related code snippets:

The AIDL file:
package com.collabera.labs.sai;

interface IMyRemoteService {

      int getCounter();

Once you write this AIDL file (.aidl) in eclipse, it will automatically generate the Remote interface corresponding to this file. The remote interface will also provide a stub inner class which has to have an implementation provided by the RemoteService class. The stub class implementation within the service class is as given here:

private IMyRemoteService.Stub myRemoteServiceStub = new IMyRemoteService.Stub() {
            public int getCounter() throws RemoteException {
                  return counter;
The onBind() method in the service class:
      public IBinder onBind(Intent arg0) {
            Log.d(getClass().getSimpleName(), "onBind()");
            return myRemoteServiceStub;

Now, let us quickly look at the meat of the service class before we move on to how the client connects to this service class. My RemoteService class is just incrementing a counter in a separate thread. This thread is created in the onStart() method as this gets certainly called whether the service is connected to by a call to startService(intent). Please read the lifecycle of a service if this needs more clarity. Here are the over-ridden onCreate(), onStart() and onDestroy() methods. Note that the resources are all released in the onDestroy() method.

      public void onCreate() {
      public void onStart(Intent intent, int startId) {
            super.onStart(intent, startId);
            serviceHandler = new Handler();
            serviceHandler.postDelayed(myTask, 1000L);
            Log.d(getClass().getSimpleName(), "onStart()");
      public void onDestroy() {
            serviceHandler = null;

A little explanation: In the onStart() method, I created a new Handler object that will spawn out a new task that implements the Runnable interface. This thread does the job of incrementing the counter. Here is the code for the Task class – an inner class of the RemoteService class.

class Task implements Runnable {
      public void run() {
            Log.i(getClass().getSimpleName(), "Incrementing counter in the run method");

An object of this Task class is passed to the serviceHandler object as a message that needs to be executed after 1 second. The Task class implements the run() method in which we repeatedly post the same message to the serviceHandler. Thus, this becomes a repeated task till all the messages in the serviceHandler queue are deleted by calling the removeCallbacks() method on the serviceHandler in the destroy() method of the RemoteService class.

Note that the onDestroy() method thus stops this thread and set the serviceHandler to null. This completes the implementation of the RemoteService class. The complete code is downloadable here.
Now coming to the client class - Here, for simplicity sake, I have put the start, stop, bind, release and invoke methods all in the same client. While in reality, one client may start and another can bind to the already started service.

There are 5 buttons one each for start, stop, bind, release and invoke actions. A client needs to bind to a service before it can invoke any method on the service.
Here are the start and the bind methods.

private void startService(){
     if (started) {
       Toast.makeText(RemoteServiceClient.this, "Service already started", Toast.LENGTH_SHORT).show();
     } else {
       Intent i = new Intent();
       i.setClassName("com.collabera.labs.sai", "com.collabera.labs.sai.RemoteService");
       started = true;
       Log.d( getClass().getSimpleName(), "startService()" );

An explicit intent is created and the service is started with the Context.startService(i) method.
Rest of the code is to update some status on the UI. There is nothing specific to a remote service invocation here. It is on the bindService() method that we see the difference from a local service.

private void bindService() {
     if(conn == null) {
        conn = new RemoteServiceConnection();
        Intent i = new Intent();
        i.setClassName("com.collabera.labs.sai", "com.collabera.labs.sai.RemoteService");
        bindService(i, conn, Context.BIND_AUTO_CREATE);
        Log.d( getClass().getSimpleName(), "bindService()" );
     } else {
       Toast.makeText(RemoteServiceClient.this, "Cannot bind - service already bound", Toast.LENGTH_SHORT).show();

Here we get a connection to the remote service through the RemoteServiceConnection class which implements ServiceConnection Interface. The connection object is required by the bindService() method – an intent, connection object and the type of binding are to be specified. So, how do we create a connection to the RemoteService? Here is the implementation:

class RemoteServiceConnection implements ServiceConnection {
      public void onServiceConnected(ComponentName className,
      IBinder boundService ) {
remoteService = IMyRemoteService.Stub.asInterface((IBinder)boundService);
            Log.d( getClass().getSimpleName(), "onServiceConnected()" );

      public void onServiceDisconnected(ComponentName className) {
            remoteService = null;
            Log.d( getClass().getSimpleName(), "onServiceDisconnected" );

The Context.BIND_AUTO_CREATE ensures that a service is created if one did not exist although the onstart() will be called only on explicit start of the service.

Once the client is bound to the service and the service has already started, we can invoke any of the methods that are exposed by the service. Here we have only one method and that is getCounter(). In this example, the invocation is done by clicking the invoke button. That would update the counter text that is below the button. 

Let us see the invoke method:

private void invokeService() {
     if(conn == null) {
        Toast.makeText(RemoteServiceClient.this, "Cannot invoke - service not bound", Toast.LENGTH_SHORT).show();
     } else {
        try {
            int counter = remoteService.getCounter();
            TextView t = (TextView)findViewById(;
            t.setText( "Counter value: "+Integer.toString( counter ) );
            Log.d( getClass().getSimpleName(), "invokeService()" );
        } catch (RemoteException re) {
            Log.e( getClass().getSimpleName(), "RemoteException" );

Once we use the service methods, we can release the service. This is done as follows (by clicking the release button):

private void releaseService() {
      if(conn != null) {
            conn = null;
            Log.d( getClass().getSimpleName(), "releaseService()" );
      } else {
            Toast.makeText(RemoteServiceClient.this, "Cannot unbind - service not bound", Toast.LENGTH_SHORT).show();

Finally we can stop the service by clicking the stop button. After this point no client can invoke this service.

private void stopService() {
      if (!started) {
            Toast.makeText(RemoteServiceClient.this, "Service not yet started", Toast.LENGTH_SHORT).show();
      } else {
            Intent i = new Intent();
            i.setClassName("com.collabera.labs.sai", "com.collabera.labs.sai.RemoteService");
            started = false;
            Log.d( getClass().getSimpleName(), "stopService()" );
These are the basics of working with a remote service on Android platform. All the best!

Addendum (updated on 6 Jan 2011) – based on many questions related to Remote services. If the client accessing the remote service is in a separate package or application, it has to include the .aidl file along with the package structure as in the Service provider.
I have written a sample remote client in a completely different application, while the remote service is the same one provided above. You may download the client app here.

NOTE on Code for download. The complete Server and client code is downloadable here. While the client alone in a separate app is here. If this client code has to work, you have to download the previous server code as well, and then use the client to start, stop, bind etc.


  1. Hi SaiGeeta ,

    Thanks a lot for your tutorial.I have one query like,

    I created a remote service .lets take like ftpserver ,it will run irresecptive of any application.Now i want to use that service in another application itself ,please let me know how we can achieve this ?

    The remoter service example given gives a picture of how service is created and used in the same applicaation (ofcourse with a diffreent thread for the service ) ,but i want to use that service in the other application.

  2. Hi,
    you have to follow the same steps mentioned in this tutorial irrespective of whether the remote service runs in the same or a separate application.
    1. To create teh FTP service as a remote service, you must create the AIDL file declaring the methods that can be invoked by clients.
    2. You have to extend the stub that is auto generated in your remote service.
    3. Apart from that you have to implement the life cycle methods of the service.
    4. Then, the service can run independently
    5. From the client program, you must create a connection object to the remote service
    6. Invoke the services declared in the remote interface by binding to the service.
    Basically what I am trying to say is that you must follow the same steps but can separate out the remote service program into one application and the client program into another application and it will work.

  3. Hi SaiGeetha

    I need one more help like ,i am trying to implement TCP/IP sockets in Android ,how to achive the same in Android ,Can you please provide the code if you have done .Also request you to add more on port forwarding stuff if you have .

    Thanks in Advance

  4. Dear Sai Geetha,

    I have separate service and client application, but I got an error message while call on service function, the message: Binder invocation to an incorrect interface. Maybe you have a some clue for me?


  5. Hi Slashwaves,

    I think you have probably created 2 interfaces in the two packages. They become different interfaces once the packages have changed. Hence you are getting the error. Ensure you use the same package interface in both the applications. It should work.

  6. Hi
    Not sure if you are familiar with "Not Call Log" application but I was wondering how it is done ... basically the application listens to outgoing call event and upon ending, it switches to HOME screen or any other that you choose ... 2 questions:
    1. Would you use service to listen for those events or ContentObserver?
    2. How do you switch between applications manually?

    Thanks in advance

  7. Hi SaiGeeta,
    I tried this example it works fine but when I tried it out in my example the service is not getting called. It say "unable to find start service intent NameOfTheService" not found error. Can you please tell why is this happening. I have made an entry in the manifest file. But still not working.

  8. Can you post the manifest file please?

  9. Hi mad_max,
    if you download my source code - link available in the article above, you will get the manifest file too. Let me know if you have any problem

  10. "This thread is created in the onStart() method as this gets certainly called whether the service is connected to by a call to startService(intent) or by bindService(…)"

    I think there is a mistake.

    From the API:
    The onCreate() and onDestroy() methods are called for all services, whether they're started by Context.startService() or Context.bindService(). However, onStart() is called only for services started by startService().

  11. Hi thanks for your tutorial,
    and i have one question.
    you said, To use remote Service between two Apps, i should make aidl file`s package same.
    but i don`t get it.
    Because, say i have two Apps which are in "com.clnt" , "com.srv",
    so each aidl file is in each package, then how can i make them to be in same package?

    so please let me know
    1. there should be aidl file in each App to use remote on different Apps?
    2. if that so, how can i do that?


  12. Hi Sai Geetha,

    I'm Abdul Muyeed here. The blog is too good. I have one doubt. We have 2 remote services running and one activity to control them. The problem is both the remote services are running with the same PID. However the activity is running in different PID. I want both the services to run on different PID. How to achieve this?

    Thanks and Regards,
    Abdul Muyeed M

  13. Hi KeniF,Thanks for pointing out,...True. onStart() is not called from a bindService() method. It is called only from startService(). Will correct in my post.
    Will also make necessary changes in the code.

  14. If you wan to start a service in a separate process (which would ensure a separate PID), you need to explicitly set the process name to a different name for one of the services. The other service will run in the default process.
    How to set the process name?
    In the Android.manifest xml, where you define your service, you can have a element as shown below:

    <service android:enabled=["true" | "false"]
    android:exported[="true" | "false"]
    android:icon="drawable resource"
    android:label="string resource"
    android:process="string" >
    . . .

    Here you set a process name - any string and that will ensure that the service runs in a separate process.
    However a warning: creating multiple processes must be avoided as it is very resource intensive and hence should be done only if it is absolutely necessary.
    Hope this helps

  15. Hi Geeta,

    Really itz great that your are contributing to open source.

    Could you please clarify the following:

    In your example you haven't created the service as remote process which can be specified in the manifest file with process attribute.Your service processname is same as application process name ie default process.As your service runs in the same process as application process (this can be viewed in the DDMS in eclipse envment)it's nothing but a local process.But you use RPC.I have also gone through API demos example
    there the remote service is invoked as separate process and so RPC is acceptable.Could you please clarify


  16. Hi,
    Nice tutorial.
    I am working on Background Service.I have one problem.I created one activity and one service.
    I invoked the service using startService(intent) method.I want to know when the service is finishing its task.while the background service finishes its task,i have to invoke a method in the activity.

    How can i do that?....please help me....

  17. Hi,
    Nice tutorial.
    I am working on Background Service.I have one problem.I created one activity and one service.
    I invoked the service using startService(intent) method.I want to know when the service is finishing its task.while the background service finishes its task,i have to invoke a method in the activity.

    How can i do that?....please help me....

  18. Hi,

    I am unable to get codes from your blog ,when i click on link to get source code it doesn't work,please update it.


  19. Hello Geeta,

    I have a problem. In the way you are getting the connection object of the service, I tried getting connection objects for two services one after another in sequence. But for some reason, i only get the connection object for one. The other is always null. Any comments / suggestions?

    Anyways, great work at your blog. I am a regular visitor to your blog.

    Thanks & Regards

    1. Hai geeta please help me to how to transefering files from pc to andoid phone and vice versa. please send the source code also


  20. hi!

    how do i bind a remote service i don't have any sources for (i.e. it is installed on my device)?

    i've written a remote service other applications should be able to query (via broadcast intents).

    is this any different than binding a remote service for which i do have the sources in my eclipse project?

  21. first of all thank you for this amazing tutorial.

    I am trying to develop an application and don't know where to start.

    the application will do following:
    - It will play music 5 known times a day (like alarm but times differ day by day),
    - It will have a widget to show how many minutes left to next music to play,
    - It will have an activity to altar alarms, add new alarms etc.

    The question is how my design should be? Is Remote Service necessary? What will update widget for every minute? I want my alarms run even though activity is killed.


  22. Hi
    Can you please update the link, I can't download source codes.

  23. Hi SaiGeetha,

    The tutorial example works great.
    I created a example having the service in different application (UI less) and the in another application. It does not recognise the IMyService and throws me error in compilation.

    Please help me

  24. Hi

    Its a very nice article but i have the following scenario...
    I have developed an android service. Any android app can use it's API's to get some kind of news updates from this service. I want to distribute this service so that any android app on the phone can use this service. My questions here are : 1: When some android application try to use its API on the phone and suppose that service is not available on the phone then what will happen ? 2: How will android application developer will make sure that the service is available on the phone ? 3: Does application developer has to bundle service with his application ? If yes then wont be there multiple instances of same service on phone if multiple application contains same service on the phone ?


  25. your post is nice . . let me tell u one thing that Blogs have become latest and important source of quality free information on net people enjoying for hours together. . .nice blog keep sharing;)
    Dissertation Writing Services

  26. Hi SaiGeetha,

    So which is the client and which is the server as both are named RemoteService and RemoteServiceClient? Thanks

  27. Hi,
    i have a question, i have a service which reads the lines from a file and continuously feed it to an activity.This all is a continuous process no breaks in between.Service will keep on reading lines from file and activity keep on working on those points....
    Please help me out how to implement this...

  28. excellent tutorial.

    not only it is working right away and is up to date, but it is well explained.

    Good job!

    greetings from Poland,

  29. its very informative tutorial, i have query How can we connect service from different project to activity in different project
    help me how can i achieve this
    i will appreciate

  30. please help me out how can i communicate activity from one project to service in another project by using .aidl
    but u tell me is there some house keeping is involve in manifest file

    i will appreciate

  31. hi sai geetha i have doubt regarding with notification to get notifications from 3rd party applications server to android app.Does this posible in android 2.1.For 2.2 google introduces c2dm service.

  32. I meam to ask how can i implement pushnotifications service in android

  33. Sai Geeta,

    I downloaded and ran your project, but when I press the "Invoke" button, the following error occurs in LogCat:

    Unable to start service Intent { cmp=com.collabera.labs.sai/.RemoteService }: not found

    The app subsequently force closes on a NullPointerException due to the service being null. This is the exact same problem I'm experiencing, and I had downloaded your project in the hope that it could show me where I was going wrong. Do you have any idea why it is unable to find the service?

  34. Hi Robert,

    You need to invoke the remote service after you start and bind it. So the order of actions needs to be: start -> bind -> invoke -> release -> stop.

    If you go through the tutorial, I hope you will understand why the order is so.

  35. HI Geetha,
    thanks for this tutorial. Its really helpful for me. I downloaded project and ran it. I am getting the same problem what Robert is getting Even though I have follow these steps start -> bind -> invoke -> release -> stop.
    I tried to removed all the previous project from the phone and ran only this project then also it didn't work.
    Please let me know what I am missing here?

  36. Thanks a lot for the very useful tutorial!

  37. Hi Sai,
    I want to compile an aidl file in android source(mydroid) and want to generate an System.img.Because the aidl file is needed by all the users of our group.Instead of writing in every application,I want to make a Centralize one.
    Where can place this aidl file to compile and generate System.img?

  38. HI Geetha,
    thanks for this tutorial. I am getting the same problem what Robert and Hame is getting Even though I have follow these steps start -> bind -> invoke -> release -> stop.
    Please let me know what I am missing here?

  39. Sai:

    Thank you for providing this information, it was very helpful.

    To those having the same problem as Robert, Hame and Sab (service not found), make sure to use the correct download link. It is provided in the paragraph that begins with the sentence "Note that the onDestroy() method thus...".

    ...perhaps Sai is also sly, and testing to see how careful we read ;)

  40. Hi I see three of you saying that the code is not working. I hope you are downloading the right source code. there are two priovided here. One consisting of the service and the service client in one package and the other consisting only of the client that can remotely (in a separate project0 invoke the service. For this the first one should have been downloaded and started and only then the second one will work.

  41. i am facing issues for setting alarm through android code.
    I gone through most of the documents on net about alarmmanager and how to use it but nothing worked.

    please find the code am using ,is it the right way for setting alarm .
    for eg: i am setting it for 8 AM morning .but its not working i am strugling on it for 3 hrs.
    i am testing it on emulator(emulator time 7.50am).
    the alarm is not starting at 8 am its just satrting at the apllication lauch time itself without waiting 10mnts
    Calendar calendar = new GregorianCalendar(); or // Calendar calendar = new Calendar();
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);

    Thanks you

  42. Hello Geetha.. i found your tutorial very helpfull... thank u... am new to this android programming... could u please send me one small project in android which on clicking the download button downloads the entered data in the form, into the database..

  43. This comment has been removed by the author.

  44. Hi Geeta,
    I am following these steps--start -> bind -> invoke still I am getting problem in invoking,Please help..

  45. Hi,

    Great tutorial, but would like to know and discuss why and when to service over asynctask for Restful Client on android.


  46. Thanks a lottt Geetha!! You are really an Angle for me!! I got exactly what I wanted!! Thankz a tonn again...
    Mayuri Ruparel

  47. nice tutorial for me who newbie in here,...

  48. Hi Sai Geetha
    I am a newbie and trying to find the way to separate client and server. I am stumble across the net and found your program. It is real nice to have someone discuss and give out the sample code. I did try use your program. However, here I got confused. I am able to bind to the service even I did not start service on another machine which I ran your server program. So, I am not sure what I did not understand. I am trying to send message from one machine to another using AIDL. Please kindly respond to this message. I am struck on this for more than a week now. Very frustrated. Please help - will be very much appreciated.


  49. Nice tutorials, I really appreciate them.

    I've been studying Android development for a while, haven't produced nothing commercial yet, hope to do it some day...

    I think that you, being a professional, participated on some projects that weren't about building stand-alone apps... meaning that in some way, the app used the Cloud (sending a file by HTTP, getting some data from a server, etc.)

    Hope you consider this domain enough "thought-provoking" to create a tutorial, I know that I and many newbies, would definitely appreciate one.

  50. Thank you for providing the code to download. It made it a lot easier to understand and truly learn! Thanks for the great tutorials. Keep it up!

  51. Did you copy code from this Blog :

    1. i think not because he is refering to this page !

  52. In the implementation of your service class you have missed declaring the exported property in the manifest file which causes startService SecurityException.

    I stumpled upon

    and found that RemoteService manifest file should have

    i.e set the exported property to true atleast if my client and server are running in 2 different packages.

  53. Somehow
    service android:name=".RemoteService" android:exported="true">
    got deleted from mypost

  54. i really like your post .. i will like to bookmark your site for my future needs :)
    dissertation writing services

  55. "If you wan to start a service in a separate process (which would ensure a separate PID), you need to explicitly set the process name to a different name for one of the services. The other service will run in the default process."

    I'm trying to run it between two apps using your ExternalClient and your RemoteService, but it fails. I need to configure some android.permission to do this, or it fails because some reference problem?

    I have tried to configure process name, but it fails too.

  56. can i put clickable buttton on status bar? how?

  57. Nice blog, just started with android services and the google dev documentation really isnt much fun, these are nice example of how to use them in code.


  58. By read your post I got good idea about public access specifier.By using this public access specifier the data can be accessed by outside the class.This is one of the valuable coding.Android app developers

  59. In one word, awsome tutorial. I love your works.

  60. I noticed one problem (when i did my own background service) during the "onStart()" method, you initialise the handler and start a postdelayed run... The problem with this is that onStart is called every time something does a startService().

    The point being that if you have serveral components trying to get to your service and they all do a startServices, you'll end up with multiple call-backs, so instead of run() being called every 5 seconds, it'll get called once every 5 seconds for each startService call.

  61. hello... many thanks for this article...
    i need to create webservice, that is calling method from other platforms(from .net)...
    do u have any example about it simply to add two numbers...
    otherwise do u know any link related to it...
    thanks in advance...

  62. Hi,

    Blinking issue found while playing two video in single activity.

    Here is my code:

    VideoView video1=(VideoView)findViewById(;
    VideoView video2=(VideoView)findViewById(;


  63. hi sai geetha,
    will u explain what is the Parcelable interface...and where will we use that interface........

  64. Hi sai Geetha,

    I have download rar of above tutorial.but can u tell me how to create AIDL file.

  65. Hello madam,
    Android is new for me.I want to create simple web service and calling or accessing that service through android application what i do? can u provide any source code and steps with explanation to building such application.plz tell me best way to doing such application.plz Help me.Hope You will think about it .plz rpy as early as possible. Thank You in advanced.

  66. This article is very informative and useful for all of us. The article has been written very well. I appreciate your work. Thanks for posting.
    dissertation writing assistance

  67. hi madam sai geetha ur blog is very help full to me

  68. Your post is awesome. You have explained it very well. I am willing to read posts like this one. Thanks for posting.
    dissertation writing software

  69. hello sai geeta i've downloaded the code for both server and client, client app has some problems of package naming in i.setclass() methode plz correct it. the only problem remaining is that i get null pointer exception when i press invoke button. i tried by buttons start bind and then invoke but get null pointer exception instead of counter value

  70. Hi Geetha,
    I have read your post Number of times.
    I have two application. I want to Inter Process communication between two application Using services, I have achieve this task using AIDL, but I want to do using services. pleas me know, how should I achieve this.
    please also add me in Linkedin.

  71. Hi Mam,
    your post is easy to understand thanks Alot 4 being posting.

  72. int counter = remoteService.getCounter();

    Getting NullPointerException on that line

  73. Hello Geetha,

    I must appreciate the simplicity and ease towards understanding the code. Keep up the good work.

    Thank you.

  74. Hi Geetha,
    well explained service bounding using aidl, it helped me a lot in understanding.
    I also tried using your same example where as client being in a different application. I am able to start or stop the service, but, have below issues,
    1. Not able to bind to the server, from logs i see this,

    09-11 11:05:22.528: I/dalvikvm(1175): Could not find method com.example.aidlexample.IMyRemoteService$Stub.asInterface, referenced from method com.example.aidlclient.AidlClient$RemoteServiceConnection.onServiceConnected
    09-11 11:05:22.528: W/dalvikvm(1175): VFY: unable to resolve static method 3058: Lcom/example/aidlexample/IMyRemoteService$Stub;.asInterface (Landroid/os/IBinder;)Lcom/example/aidlexample/IMyRemoteService;
    09-11 11:05:22.537: D/dalvikvm(1175): VFY: replacing opcode 0x71 at 0x0002
    09-11 11:05:22.537: W/dalvikvm(1175): VFY: unable to find class referenced in signature (Lcom/example/aidlexample/IMyRemoteService;)
    09-11 11:05:22.547: W/ActivityManager(159): Unable to start service Intent { cmp=com.example.aidlexample/.RemoteService }: not found
    2. when try to invoke the service, i get a force close with below logs,

    09-11 11:06:03.998: E/AndroidRuntime(1175): FATAL EXCEPTION: main
    09-11 11:06:03.998: E/AndroidRuntime(1175): java.lang.NoSuchMethodError: com.example.aidlexample.IMyRemoteService.getCounter
    09-11 11:06:03.998: E/AndroidRuntime(1175): at com.example.aidlclient.AidlClient.invokeService(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at com.example.aidlclient.AidlClient.access$4(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at com.example.aidlclient.AidlClient$1.onClick(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at android.view.View.performClick(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at android.view.View$
    09-11 11:06:03.998: E/AndroidRuntime(1175): at android.os.Handler.handleCallback(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at android.os.Handler.dispatchMessage(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at android.os.Looper.loop(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at
    09-11 11:06:03.998: E/AndroidRuntime(1175): at java.lang.reflect.Method.invokeNative(Native Method)
    09-11 11:06:03.998: E/AndroidRuntime(1175): at java.lang.reflect.Method.invoke(
    09-11 11:06:03.998: E/AndroidRuntime(1175): at$
    09-11 11:06:03.998: E/AndroidRuntime(1175): at
    09-11 11:06:03.998: E/AndroidRuntime(1175): at dalvik.system.NativeStart.main(Native Method)

    If you can help in identifying the issue it would help in making my understanding even good about aidl,
    -Thanks & regards,

  75. This comment has been removed by the author.

  76. You are an inspiration to Indian women :)

  77. Hi Sai Geetha.

    Thanks for your topic.

    I'm new in Android and have a problem, but my English is very very terrible.
    My problem about: I usually receive sms from number "0123456789" day by day, it's a obtrusion. I want to create a small first app in Android but i do it myself. I read about this topic in:

    It gave me so much time but the result is nothing. I hope so You can help me to create a SERVICE for it.

    Waiting your answer day by day!

  78. HI Geeta,

    I want to start the background service from the AppWidget which is on Home screen .I try for the same but not able to implement it.Can you help ?

  79. hai geetha....
    im new to android programming....
    hw cn i update the datas in mobiledatabase(sqlite) to a wesite???

  80. Hai geetha! i implement your services with notifications example! my question is this .

    you said that local services's life is dependent on the activity that started it. but when i start the service from my activity and then close my activity but the service was still running. now why is that? if i am mistaking please help me!

    1. This comment has been removed by the author.

  81. Hi geetha,

    Nice tutorial, I was just wondering what is the updateServiceStatus method about?

  82. Thanks a lot for providing such a nice information. It will be really useful for android developers. The way you expressed your code stuns good. My friend who is an Android developer has the great passion in developing the android application. I will take forward this blog to my friend, so that he will get benefited by reading your blog.

  83. Is it possible to create aidl in 1 app and access it from other app.
    can u share example.
    i tried by making 1 app[service] as lib and by adding it to my other app but still security exception is there.