我正在我的应用程序中创建一项服务。这是我使用的代码。
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();
}
}
也在清单文件中的应用程序标签内定义
<service android:name=".LocationService"
android:process=":LocationService">
</service>
在 Activity 的 onCreate 方法中调用此 Service
Context context = this;
Intent service = new Intent(context, LocationService.class);
service.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(service);
但是这个服务没有启动。我在 LogCat 窗口中看不到任何日志消息请帮助