这是我的onBackpressed():
@Override
public void onBackpressed() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(MainScreen.this);
String checkInVal = preferences.getString("checkIn","");
if (!PRE_USER_actIVE.equalsIgnoreCase("1")) {
super.onBackpressed();
finish();
} else if (MainScreen.this.getSupportFragmentManager().findFragmentByTag("VOLUNTEERDetaILS") != null && checkInVal.equals("yes")) {
popFragment();
} else {
if (Functions.iNumberOfLoadedFragments == 0) {
String exitLog = "Exit Application",ok = "OK",cancel = "CANCEL";
String sureLog = "Are you sure you want to exit " + MainScreen.this.getResources().getString(R.string.app_name);
if (EasyPreference.with(MainScreen.this,PRE_KEY)
.getString(PRE_USER_LANGUAGE,PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_ASSEMESS)) {
exitLog = "প্ৰস্থান কৰক অ্যাপ্লিকেশন";
sureLog = "আপুনি Our SchoolZoneৰ পৰা প্ৰস্থান কৰিবলৈ নিশ্চিতনে";
ok = "স্বীকাৰ কৰক";
cancel = "বাতিল কৰক";
} else if (EasyPreference.with(MainScreen.this,PRE_LANGUAGE_ENGLISH).equalsIgnoreCase(PRE_LANGUAGE_THI)) {
exitLog = "ออกจากแอพพลิเคชัน";
sureLog = "คุณแน่ใจหรือว่าต้องการออกจาก Our SchoolZone";
ok = "ตกลง";
cancel = "ยกเลิก";
}
new LovelyStandardDialog(MainScreen.this)
.setTopColor(Functions.getBackColor())
.setIcon(R.drawable.ic_info_outline_white_36dp)
.setTitle(exitLog)
.setMessage(sureLog)
.setPositiveButton(ok,new View.OnClicklistener() {
@Override
public void onClick(View v) {
MainScreen.super.onBackpressed();
}
})
.setNegativeButton(cancel,new View.OnClicklistener() {
@Override
public void onClick(View v) {
}
})
.show();
} else if (Functions.iNumberOfLoadedFragments > 0) {
Functions.iNumberOfLoadedFragments--;
super.onBackpressed();
}
}
}
需要在此活动按下的后退按钮中显示ALertDialog 相反,该应用仅退出启动器。
可能出现的问题,请回复您的宝贵建议。谢谢