【问题标题】:how to set alert dialog box open until status change如何设置警报对话框打开直到状态更改
【发布时间】:2015-03-14 00:04:52
【问题描述】:

我有一个警告对话框,当互联网连接不存在时会显示。我删除了“确定”按钮,以便用户无法关闭它。但是如果internet的状态已经变成on了怎么关闭呢?!

这是我的警报对话框的代码:

public void showAlertDialog(Context context, String title, String message, Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();

    // Setting Dialog Title
    alertDialog.setTitle(title);

    // Setting Dialog Message
    alertDialog.setMessage(message);

    // Setting alert dialog icon
    alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);


    // Showing Alert Message
    alertDialog.show();
}

我是这样称呼它的:

// check for Internet status
    if (isInternetPresent) {
        // Internet Connection is Present
        // make HTTP requests
        switch (v.getId()) { 
        case R.id.btn_login: 

            new AttemptLogin().execute();


        default:
            break;
        }
    } else {
        // Internet connection is not present
        // Ask user to connect to Internet
        showAlertDialog(Login.this, "No Internet Connection",
                "You don't have internet connection.", false);
    }

【问题讨论】:

    标签: java android


    【解决方案1】:

    尝试使用BroadcastReciver 来收听ConnectivityManager.CONNECTIVITY_ACTION

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-15
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-25
      相关资源
      最近更新 更多