我试图编写一个Android程序,其中有2个服务,一个用于蓝牙连接,另一个用于调用蓝牙连接服务中的方法。我想知道我是否可以将这两种服务捆绑在一起,我试过但是卡住了
当我尝试将其绑定到蓝牙服务时,此代码来自第二服务
public class ActionHandler extends Service {
BTservice btService;
boolean mBound = false;
private final IBinder mBinder = new LocalBinder();
public class LocalBinder extends Binder {
ActionHandler getService() {
// Return this instance of LocalService so clients can call public methods
return ActionHandler.this;
}
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return mBinder;
}
@Override
public int onStartCommand(Intent in, int flags, int startId) {
// TODO Auto-generated method stub
//Bind to Service
Intent intent = new Intent(this,BTservice.class);
bindService(intent,mConnection,Context.BIND_AUTO_CREATE);
return START_STICKY;
}
/** Defines callbacks for service binding, passed to bindService() */
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName className,
IBinder service) {
// We've bound to LocalService, cast the IBinder and get LocalService instance
LocalBinder binder = (LocalBinder) service;
btService = binder.getService();
mBound = true;
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
mBound = false;
}
};
}
eclipse说btService类型不匹配,我该怎么办?