나는 안드로이드에서 원격 서비스로 조금 붙어있다. 것은 내가 패키지 "a.b.c"에서 원격 서비스를 구현하고 다른 응용 프로그램이이 서비스에 액세스 할 수 있기를 원합니다. 나는 모든 진절머리 나는 보조 장치를 제거하고 방송 된 의도를 통해 작동하도록 서비스의 "인터페이스"를 설계했습니다. 지금까지 잘 작동합니다 ...다른 앱 (다른 패키지)에 구현 된 Android 서비스에서 원격 서비스를 시작하고 바인딩하는 방법은 무엇입니까?
문제는 : 서비스를 시작/중지하려면 different
응용 프로그램 (다른 패키지, 다른 프로젝트, 어쩌면 다른 개발자 ...)을 얻으려면 어떻게합니까?
package d.e.f;
import a.b.c.*;
public class main extends Activity {
protected ImyService myService;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent = new Intent(ImyService.class.getName());
bindService(intent, sConnection, Context.BIND_AUTO_CREATE);
}
protected ServiceConnection sConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder binder) {
wlService = ImyService.Stub.asInterface(binder);
ServiceConnected = true;
Toast.makeText(main.this, "service connected", Toast.LENGTH_SHORT).show();
}
public void onServiceDisconnected(ComponentName className) {
wlService = null;
ServiceConnected = false;
Toast.makeText(main.this, "service disconnected", Toast.LENGTH_SHORT).show();
}
};
}
이렇게하면 시작할 때 내 앱이 즉시 중단됩니다. 내가 뭘 잘못 했니? 이게 어떻게 작동할까요?
일단 실행되면 명령과 데이터가 브로드 캐스트를 통해 전달됩니다. 그래서 진짜 문제가 안된다.
작품 사용
Intent
에 대한 해당 작업의 문자열을 사용! – Ben@JPM : https://github.com/commonsguy/cw-advandroid/blob/master/AdvServices/RemoteService/AndroidManifest.xml – CommonsWare
LOL thatss so simple ... 그러나 천재. 네가 할 수 있다는 것을 몰랐어. 고마워. – JPM