Skip to content

Instantly share code, notes, and snippets.

@dearsq
Last active August 17, 2018 09:27
Show Gist options
  • Save dearsq/aa7556460309cd3f0e8c652207848df4 to your computer and use it in GitHub Desktop.
Save dearsq/aa7556460309cd3f0e8c652207848df4 to your computer and use it in GitHub Desktop.
[控件_AlertDialog] 警告对话框 #Android
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle("Warning");
            builder.setMessage("You are forced to be offline. Please try to login again.");
            builder.setCancelable(false); // 设置为不可取消
            builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ActivityCollector.finishAll(); // 销毁所有的活动
                    Intent intent = new Intent(context , LoginActivity.class);
                    context.startActivity(intent); // 重新启动 LoginActivity
                }
            });
            builder.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment