问题描述
- android Service中onStartCommand()方法什么时候被调用?
-
写了一个类继承Service,在service里面写了定位监听。然后new方法创建类对象,成功实现了定位;但是在onStartCommand()方法里面的代码,并没有执行;
通过Intent localIntent = new Intent(this, MyLocationService.class);
startService(localIntent);onStartCommand()里面的方法才被执行,这是为什么呢?
时间: 2024-09-14 19:01:00