내 활동에서 보낸 인 텐트를 사용하여 내 서비스의 특정 기능을 호출하려고합니다. 내가 할 몇 통화 후여러 개의 의도로 "알 수없는 서비스 시작 결과"오류가 발생합니다.
@Override
public int onStartCommand (Intent intent, int flags, int startId){
super.onStartCommand(intent, flags, startId);
if(intent.getAction().equals(INTENT_ACTIVITY_START)){
Toast.makeText(this,"onStartCommand ...", Toast.LENGTH_SHORT).show();
}else if(intent.getAction().equals(INTENT_ACTIVITY_POSITION_CHANGED)){
// here comes some code to get extras from intent
Log.d("INTENT_ACTIVITY_POSITION_CHANGED", "x=" + posX + " y=" + posY);
//TODO preveri
}
return startId;
}
:
Intent it = new Intent(MyService.INTENT_ACTIVITY_POSITION_CHANGED);
it.setClass(getApplicationContext(), MyService.class);
it.putExtra("posPercentX", x);
it.putExtra("posPercentY", y);
startService(it);
이 내 onStartCommand이이면 MyService처럼 보이는 방법입니다
이 내가 (UI 스레드에서) 활동에서 텐트를 보낼 방법입니다 :
ERROR/ActivityManager(52): java.lang.IllegalArgumentException: Unknown service start result: 4
왜이 오류가 발생합니까? 어떤 생각?
ㅎㅎ 감사에서 START_STICKY, 또는 값 중 하나를 반환해야 비트. 나는 여전히 안드로이드에 대해 알게되고 잘못된 반환 값이 나에게는 분명하지 않다. – danizmax
걱정할 필요가 없습니다. 나는 거시기처럼 들릴 수는 있지만, 개인적인 것은 아닙니다. P – Falmarri