내 응용 프로그램에 서비스를 만들고 있습니다. 여기에 제가 사용한 코드가 있습니다.Android 서비스가 시작되지 않았습니다.
public class LocationService extends Service{
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Log.e("Location Service", "onStrat of service");
}
@Override
public void onCreate() {
super.onCreate();
Log.e("Location Service", "onCreate of service");
LocationOperations locationOperations = new LocationOperations(getBaseContext());
locationOperations.retrieveLocation();
}
}
는 또한 활동
Context context = this;
Intent service = new Intent(context, LocationService.class);
service.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(service);
의에서 onCreate 방법에서이 서비스를 호출하는 applicatoin 태그
<service android:name=".LocationService"
android:process=":LocationService">
</service>
내에서 매니페스트 파일에 정의하지만이 서비스가 아닌 LogCat 창에서 로그 메시지를 볼 수 없습니다. 도와주세요.
http://stackoverflow.com/questions/4759676/why-is-this-simple-service-not-starting – Nermeen
왜 서비스를 별도의 프로세스로 만들고 있습니까? –
Beacause GPS, WIFI 또는 셀 타워를 통해 위치 좌표를 얻으려면 응용 프로그램이 닫힐 때까지 계속해서 사용할 수 있어야합니다. 그래서 나는 백그라운드 스레드에서 실행 싶었어요. –