// ---------------------------------------------------------------------
// CallBackF call = new CallBackF()
// {
// @Override
// public void F()
// {
// // 退出逻辑
// }
// };
//
// QuitCustom(activity, call);
public interface CallBackF
{
// 回调处理逻辑
public void F();
}
// demo自定义退出逻辑
public static void QuitCustom(Context context, final CallBackF call)
{
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle("确认退出?");
dialog.setIcon(android.R.drawable.ic_dialog_info);
dialog.setPositiveButton("确定", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
if (call != null) // 执行回调处理逻辑
call.F();
else System.exit(0); // 退出运行
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// 点击“返回”后的操作,这里不设置没有任何操作
}
});
dialog.show();
}