【发布时间】:2016-04-11 11:23:24
【问题描述】:
这是我的服务连接:
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"/>
我是否试图错误地绑定它?为什么不调用。
【问题讨论】:
-
没有它会启动吗?
-
去掉startService还是不行
标签: android service bind serviceconnection bindservice