アプリケーションでサービスを作成しています。これが私が使用したコードです。
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();
}
}
applicatoin タグ内のマニフェスト ファイルにも定義します。
<service android:name=".LocationService"
android:process=":LocationService">
</service>
アクティビティの onCreate メソッドでこのサービスを呼び出す
Context context = this;
Intent service = new Intent(context, LocationService.class);
service.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(service);
しかし、このサービスは開始されていません。LogCat ウィンドウにログ メッセージが表示されません。助けてください