这是我的服务连接:
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
Log.i("","onServiceConnected TRUE");
locationService = ((LocationService.ServiceBinder)service).getService();
}
public void onServiceDisconnected(ComponentName className) {
Log.i("","onServiceConnected TRUE DISCONNECT");
locationService = null;
}
};
这是永远不会输入的。我这样称呼它:
void doBindService() {
bindService(new Intent(this, LocationService.class), mConnection, Context.BIND_AUTO_CREATE);
}
从我的 ApplicationClass onCreate:
Intent i= new Intent(PSLocationCenter.this, LocationService.class);
startService(i);
doBindService();
我在清单中有这个:
<service android:name=".services.LocationService" android:enabled="true"/>
我试图错误地绑定它吗?为什么不叫。