Source:
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.actionSettings: Intent i = new Intent(this, SettingsActivity.class); startActivity(i); return true; case R.id.actionSearchLocal: return true; case R.id.actionLogout: this.showLogoutDialog(); return true; case R.id.syncbutton: boolean syncState = OpenMRS.getInstance().getSyncState(); if (syncState) { OpenMRS.getInstance().setSyncState(false); setSyncButtonState(false); showNoInternetConnectionSnackbar(); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.disconn_server); } else if (NetworkUtils.hasNetwork()) { OpenMRS.getInstance().setSyncState(true); setSyncButtonState(true); Intent intent = new Intent("org.openmrs.mobile.intent.action.SYNC_PATIENTS"); getApplicationContext().sendBroadcast(intent); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.reconn_server); if (snackbar != null) snackbar.dismiss(); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.SUCCESS, R.string.connected_to_server_message); } else { showNoInternetConnectionSnackbar(); } return true; case R.id.actionLocation: if (!locationList.isEmpty()) { locationList.clear(); } Observable<List<Location>> observableList = new LocationDAO().getLocations(); observableList.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(getLocationList()); return true; case R.id.actionAbout: Intent j = new Intent(this, AboutActivity.class); startActivity(j); default: return super.onOptionsItemSelected(item); } }

Target:
public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.actionSettings: Intent i = new Intent(this, SettingsActivity.class); startActivity(i); return true; case R.id.actionSearchLocal: return true; case R.id.actionLogout: this.showLogoutDialog(); return true; case R.id.syncbutton: boolean syncState = OpenMRS.getInstance().getSyncState(); if (syncState) { OpenMRS.getInstance().setSyncState(false); setSyncButtonState(false); showNoInternetConnectionSnackbar(); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.disconn_server); } else if (NetworkUtils.hasNetwork()) { OpenMRS.getInstance().setSyncState(true); setSyncButtonState(true); Intent intent = new Intent("org.openmrs.mobile.intent.action.SYNC_PATIENTS"); getApplicationContext().sendBroadcast(intent); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.NOTICE, R.string.reconn_server); if (snackbar != null) snackbar.dismiss(); ToastUtil.showShortToast(getApplicationContext(), ToastUtil.ToastType.SUCCESS, R.string.connected_to_server_message); } else { showNoInternetConnectionSnackbar(); } return true; case R.id.actionLocation: if (!locationList.isEmpty()) { locationList.clear(); } Observable<List<Location>> observableList = new LocationDAO().getLocations(); observableList.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(getLocationList()); return true; case R.id.actionAbout: Intent about = new Intent(this, AboutActivity.class); startActivity(about); default: return super.onOptionsItemSelected(item); } }