Я делаю это в своем приложении, но мне не удается передать переменные toRec и camp:
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
mBoundService = ((SensorService.LocalBinder)service).getService();
Toast.makeText(SensorsState.this, R.string.local_service_connected,
Toast.LENGTH_SHORT).show();
mBoundService.toRec=toRec;
mBoundService.camp=CAMPIONI_FFT;
}
public void onServiceDisconnected(ComponentName className) {
mBoundService = null;
Toast.makeText(SensorsState.this, R.string.local_service_disconnected,
Toast.LENGTH_SHORT).show();
}
};
void doBindService() {
bindService(new Intent(SensorsState.this,
SensorService.class), mConnection, Context.BIND_AUTO_CREATE);
mIsBound = true;
}
void doUnbindService() {
if (mIsBound) {
unbindService(mConnection);
mIsBound = false;
}
}
@Override
protected void onDestroy() {
super.onDestroy();
doUnbindService();
}
Tnk в