0

I have a remote service, a remote service interface and a client bind to it. I wonder if it is possible to call methods(eg. UnexposedMethod2) in service which are not exposed in interface on service's context.

My code is as following:

SomeService.java:

public class SomeService extends IntentService {
    private IRemote.Stub iremote_sub = new IRemote.Stub(){
        public String SomeMethod(String key) throws RemoteException {
            return SomeService.this.UnexposedMethod1(key);
        }
    };

    private String UnexposedMethod1(String key){
        /* Do Something With key */
        ........................

        return UnexposedMethod2();
    }

    public String UnexposedMethod2(){
        String str = new String();

        /* Do Something With str and Fetch Data from Providers */
        return str;
    }

}

IRemote.aidl:

interface IRemote{
    String SomeMethod(String key)
}

SomeActivity.java:

public class SomeActivity extends Activity {
    private ServiceConnection myConnection = new ServiceConnection() {
        public void onServiceConnected(ComponentName className, IBinder service) {

            myService = IGetContactsString.Stub.asInterface(service);

    /* Can I call UnexposedMethod2 here on service's context? */
        }

        public void onServiceDisconnected(ComponentName className) {
            myService = null;
        }
    };  
}

Any advice is helpful. Many thanks!

yoarcher
  • 5
  • 1
  • 3
  • Do you definitely need [AIDL](http://developer.android.com/guide/components/aidl.html)? – Ken Wolf May 31 '13 at 16:53
  • Thanks for your reply. In this case, only the remote service has the permission to providers, so I think all movements should be on service's context. So aidl seems needed. @KenWolf – yoarcher May 31 '13 at 17:57

0 Answers0