Код: Выделить всё
public void onClickImageButton(View view) {
// try stopping, otherwise start
Context context = getApplicationContext();
Intent intent = new Intent(context, SpeechRecognitionService.class);
if(context.stopService(intent)) {
ImageButton button = this.findViewById(R.id.imageButton);
button.setColorFilter(Color.argb(255, 60, 47, 47));
isBound = false;
} else {
intent = new Intent(context, SpeechRecognitionService.class);
context.startForegroundService(intent);
bindService(intent, connection, Context.BIND_AUTO_CREATE);
}
}
Код: Выделить всё
context.stopService(intent)В onStartCommand() моего класса службы< /code> Он возвращает START_STICKY. Я попробовал START_NOT_STICKY, но безрезультатно.
Подробнее здесь: https://stackoverflow.com/questions/786 ... the-client
Мобильная версия