@Test public void shouldToastWarningMessageWhenClickBackButtonFirstTime() { homeActivity.onBackPressed(); String warningMessage = ShadowToast.getTextOfLatestToast(); assertThat(warningMessage, equalTo(homeActivity.getString(R.string.msg_back_twice_to_exit))); }
@Override public void onBackPressed() { if (exitPressedOnce) { moveTaskToBack(true); } else { ToastUtil.show(R.string.msg_back_twice_to_exit); new Handler().postDelayed(() -> exitPressedOnce = false, BACK_TWICE_INTERVAL); } exitPressedOnce = !exitPressedOnce; }
HomeActivity extends BaseActivity { @Override public void onBackPressed() { if (exitPressedOnce) { moveTaskToBack(true); } else { ToastUtil.show(R.string.msg_back_twice_to_exit); new Handler().postDelayed(() -> exitPressedOnce = false, BACK_TWICE_INTERVAL); } exitPressedOnce = !exitPressedOnce; } }
HomeActivity extends BaseActivity { @Override public void onBackPressed() { if (exitPressedOnce) { moveTaskToBack(true); } else { ToastUtil.show(R.string.msg_back_twice_to_exit); new Handler().postDelayed(() -> exitPressedOnce = false, BACK_TWICE_INTERVAL); } exitPressedOnce = !exitPressedOnce; }  }
HomeActivity extends BaseActivity { @Override public void onBackPressed() { if (exitPressedOnce) { moveTaskToBack(true); } else { ToastUtil.show(R.string.msg_back_twice_to_exit); new Handler().postDelayed(() -> exitPressedOnce = false, BACK_TWICE_INTERVAL); } exitPressedOnce = !exitPressedOnce; }  void onClickStockCard(View view); void onClickKitStockCard(View view); void onClickInventory(View view); void onClickPatientDataReport(View view); void onClickRapidTestHistory(View view); void onClickAL(View view); void syncData(); void onClickMMIAHistory(View view); void onClickVIAHistory(View view); void onClickPtvStockCard(View view); @Override void onBackPressed(); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); static Intent getIntentToMe(Context context); }
HomeActivity extends BaseActivity { @Override public void onBackPressed() { if (exitPressedOnce) { moveTaskToBack(true); } else { ToastUtil.show(R.string.msg_back_twice_to_exit); new Handler().postDelayed(() -> exitPressedOnce = false, BACK_TWICE_INTERVAL); } exitPressedOnce = !exitPressedOnce; }  void onClickStockCard(View view); void onClickKitStockCard(View view); void onClickInventory(View view); void onClickPatientDataReport(View view); void onClickRapidTestHistory(View view); void onClickAL(View view); void syncData(); void onClickMMIAHistory(View view); void onClickVIAHistory(View view); void onClickPtvStockCard(View view); @Override void onBackPressed(); @Override boolean onCreateOptionsMenu(Menu menu); @Override boolean onPrepareOptionsMenu(Menu menu); @Override boolean onOptionsItemSelected(MenuItem item); static Intent getIntentToMe(Context context);  }