Как я могу начать и привязаться к сервису в Android?JAVA

Программисты JAVA общаются здесь
Anonymous
Как я могу начать и привязаться к сервису в Android?

Сообщение Anonymous »

Я пытаюсь запустить службу в Android :

Код: Выделить всё

Log.d("BLE", "Start Service");
Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
startService(gattServiceIntent);
Log.d("BLE", "Service Started");
В функции Bluetoothleservice I переопределяю функцию OnStartCommand () , что означает, что я увижу журнал Когда служба запускается

Код: Выделить всё

public class BluetoothLeService extends Service {
....
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
// Let it continue running until it is stopped.
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
Log.d("BLE", "onStartCommand");
return START_STICKY;
}
< /code>

Однако журнал < /code> является следующим: < /p>

07-14 21:30:23.676: D/BLE(28327): Start Service
07-14 21:30:23.676: D/BLE(28327): Service Started
Но onstartcommand () никогда не появлялся в журнале . Как я могу начать службу?

Подробнее здесь: https://stackoverflow.com/questions/247 ... in-android

Вернуться в «JAVA»