@Override public boolean onOptionsItemSelected(MenuItem item) { if (btService != null) { btService.stopSelf(); btService = null; } finish(); return super.onOptionsItemSelected(item); }
@Override protected void onDestroy() { if (btService != null) { btService.unregisterChannel(CHANNEL_ID); } if (btService != null && shouldStop) { btService.stopSelf(); } unbindService(connection); super.onDestroy(); }