사용법은 로컬 서비스랑 비슷합니다. 다만 AndroidManifest.xml에 선언할때 android:process=":remote" 적어 줘야합니다.
<service android:name="test.app.RemoteService"
android:process=":remote"
android:exported="true">
<intent-filter> <action android:name="test.app.RemoteService" /> </intent-filter>
</service>
다른 앱인경우 즉 패키지가 다른경우
android:exported="true"
AIDL 선언한뒤에 사용해도 되고 Messenger를 사용해도 됩니다.
( https://developer.android.com/guide/components/bound-services 참고) 인터넷에 검색하면 예제 많이 나옵니다.(http://www.marioalmeida.eu/2014/02/21/how-to-do-android-ipc-using-messenger-to-a-remote-service/)
바이드 호출할때 패키지 설정해 주시고(클래스 패키지가 아니라 어플리케이션 패키지), 액션설정하시고 호출하면 됩니다. 물론 서비스에 해당 액션에 대한 인텐트 필터를 설정해 주셔야합니다.
Intent intent = new Intent();
intent.setPackage("kr.luxsoft.test"); // 서비스를 포함하는 어플리케이션 패키지 이름
intent.setAction("test.app.RemoteService"); // 액션이름 , 다른것 설정해도 상관없습니다. 대신 인텐트 필터도 동일하게 설정해야합니다.
bindService( intent, mConnection, Context.BIND_AUTO_CREATE);