Example usage for android.app AlertDialog.Builder show

List of usage examples for android.app AlertDialog.Builder show

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:br.com.GUI.perfil.PerfilAluno.java

public void atualizarDadosAluno() {

    if (nome.getText().toString() == null) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
        alertDialog.setTitle("Ateno");
        alertDialog.setMessage("Por favor, digite o seu nome");
        alertDialog.setIcon(R.drawable.critical);
        alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();/*www .j  a v  a 2  s. c o  m*/
            }
        });

        alertDialog.show();
    } else {
        byte[] byteFoto = ImageUtils.bitmapToByteArray(bmp);
        String fotoAluno = new String(byteFoto);

        String dataDeNascimento = dataNascimentoDia.getValue() + "/" + dataNascimentoMes.getValue() + "/"
                + dataNascimentoAno.getValue();

        final Aluno a = new Aluno(telefone.getText().toString(), nome.getText().toString(), dataDeNascimento,
                email.getText().toString(), null, pref.getString("usuario", null),
                pref.getString("senha", null), null, 0, 0, fotoAluno, 0);

        boolean r = a.atualizarAlunoWeb();

        if (r && a.atualizar(b, byteFoto)) {
            Toast.makeText(getActivity(), "Atualizado com Sucesso", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getActivity(), "Erro ao salvar no servidor", Toast.LENGTH_SHORT).show();
        }
    }

}

From source file:com.nbplus.hybrid.BasicWebViewClient.java

@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
    mPageLoadSuccess = false;/* w  w w . j  a v  a2 s. c  om*/
    Log.e(TAG, "WebView client onReceivedError code = " + errorCode);
    switch (errorCode) {
    case ERROR_AUTHENTICATION: // ? ? ?? 
    case ERROR_BAD_URL: // ? URL
    case ERROR_CONNECT: //   
    case ERROR_FAILED_SSL_HANDSHAKE: // SSL handshake  
    case ERROR_FILE: // ? ? 
    case ERROR_FILE_NOT_FOUND: // ?? ?  
    case ERROR_HOST_LOOKUP: //  ? ?  ?  
    case ERROR_IO: // ? ?   
    case ERROR_PROXY_AUTHENTICATION: // ?? ? ?? 
    case ERROR_REDIRECT_LOOP: //  ? 
    case ERROR_TIMEOUT: //   
    case ERROR_TOO_MANY_REQUESTS: // ?   ?  ?
    case ERROR_UNKNOWN: // ? 
    case ERROR_UNSUPPORTED_AUTH_SCHEME: // ??  ?? 
    case ERROR_UNSUPPORTED_SCHEME:
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                closeWebApplication();
            }
        });
        builder.setMessage(R.string.webview_page_loading_error);
        builder.show();

        dismissProgressDialog();
        // Default behaviour
        super.onReceivedError(view, errorCode, description, failingUrl);
    }
}

From source file:com.google.zxing.client.android.history.HistoryActivity.java

public void limpaHistorico() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this, 3);
    builder.setMessage(R.string.msg_sure);
    builder.setCancelable(true);//from   w w  w .ja  v  a2s.co m
    builder.setPositiveButton(R.string.button_ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i2) {
            historyManager.clearHistory();
            dialog.dismiss();
            finish();
        }
    });
    builder.setNegativeButton(R.string.button_cancel, null);
    builder.show();
}

From source file:com.spoiledmilk.ibikecph.IssuesActivity.java

public void onButtonSendClick(View v) {
    if (currentOption != null) {
        new Thread(new Runnable() {
            @Override//from   w  w  w.  j a  v  a  2s  .  c  om
            public void run() {
                JsonNode response = null;
                JSONObject jsonPost = new JSONObject();
                String auth_token = IbikeApplication.getAuthToken();
                try {
                    jsonPost.put("auth_token", auth_token);
                    JSONObject jsonIssue = new JSONObject();
                    jsonIssue.put("route_segment", spinner.getSelectedItem().toString());
                    jsonIssue.put("error_type", currentOption.getText().toString());
                    String comment = "";
                    comment += IbikeApplication.getString("report_from") + "\n";
                    comment += startName + "\n" + startLoc + "\n\n";
                    comment += IbikeApplication.getString("report_to") + "\n";
                    comment += endName + "\n" + endLoc + "\n\n";
                    comment += IbikeApplication.getString("report_reason") + "\n";
                    comment += currentOption.getText().toString() + "\n\n";
                    comment += (currentComment == null ? "" : currentComment.getText().toString()) + "\n\n";
                    comment += spinner.getSelectedItem().toString() + "\n\n";
                    comment += IbikeApplication.getString("report_tbt_instructions") + "\n";
                    for (String turn : turns) {
                        comment += turn + "\n";
                    }
                    jsonIssue.put("comment", comment);
                    jsonPost.put("issue", jsonIssue);
                    response = HttpUtils.postToServer(Config.serverUrl + "/issues", jsonPost);
                    IbikeApplication.getTracker().sendEvent("Report", "Completed", "", (long) 0);
                } catch (JSONException e) {
                    LOG.e(e.getLocalizedMessage());
                } finally {
                    final JsonNode responseTemp = response;
                    IssuesActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            String message = IbikeApplication.getString("Error");
                            if (responseTemp != null && responseTemp.has("info")) {
                                message = responseTemp.get("info").asText();
                                LOG.d("issues response message = " + message);
                            }
                            AlertDialog.Builder builder = new AlertDialog.Builder(IssuesActivity.this);
                            builder.setMessage(message);
                            builder.setPositiveButton("OK", new OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    dialog.dismiss();
                                    finish();
                                    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
                                }
                            });
                            builder.show();
                        }
                    });

                }
            }
        }).start();

    }
}

From source file:br.com.GUI.perfil.PerfilPersonal.java

public void atualizarDadosPersonal() {

    if (nome.getText().toString() == null) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
        alertDialog.setTitle("Ateno");
        alertDialog.setMessage("Por favor, digite o seu nome");
        alertDialog.setIcon(R.drawable.critical);
        alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();/*from   w w  w  .  j  av a 2s  .  c o  m*/
            }
        });

        alertDialog.show();
    } else {

        byte[] byteFoto = ImageUtils.bitmapToByteArray(bmp);
        String fotoPersonal = Base64.encodeToString(byteFoto, 0);

        String dataDeNascimento = dataNascimentoDia.getValue() + "/" + dataNascimentoMes.getValue() + "/"
                + dataNascimentoAno.getValue();

        final Personal p = new Personal(telefone.getText().toString(), nome.getText().toString(),
                dataDeNascimento, email.getText().toString(), pref.getString("sexo", null),
                pref.getString("usuario", null), pref.getString("senha", null), fotoPersonal);

        boolean r = p.atualizarPersonalWeb();

        if (r && p.atualizar(b, byteFoto)) {
            Toast.makeText(getActivity(), "Atualizado com Sucesso", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getActivity(), "Erro ao salvar no servidor", Toast.LENGTH_SHORT).show();

        }
    }
}

From source file:com.epunchit.user.FacebookActivity.java

public void inviteFriendsConfirmDialog() {
    final AlertDialog.Builder alert = new AlertDialog.Builder(mActivity);
    String title = "Are you sure you like to send this invite?";
    alert.setTitle(title);//from ww w. j  a v a  2  s  . c  o m
    alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            postOnWall();
            postUserEvent();
        }
    });
    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    alert.show();
}

From source file:com.googlecode.CallerLookup.Main.java

public void doHelp() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle(R.string.HelpTitle);/*from  w  ww.ja va2 s  .  c o m*/
    alert.setMessage(R.string.HelpMessage);
    alert.setPositiveButton(android.R.string.ok, null);
    alert.show();
}

From source file:com.guardtrax.ui.screens.SplashScreen.java

private void initialize() {
    if (locationManagerObj == null) {
        locationManagerObj = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

        try {//from w  w  w  .j  a  va 2  s.c o  m
            gps_enabled = locationManagerObj.isProviderEnabled(LocationManager.GPS_PROVIDER);

            //network_enabled = locationManagerObj.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        } catch (Exception ex) {
        }
    }

    // don't start listeners if no provider is enabled - Changed to to look for both
    //if (!gps_enabled) 
    if (!gps_enabled && !network_enabled) {
        AlertDialog.Builder dialog = new AlertDialog.Builder(SplashScreen.this);
        dialog.setTitle("Info");
        dialog.setMessage("Please enable GPS!");
        dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                System.exit(0);
            }
        });
        dialog.show();
    } else {
        Runnable showWaitDialog = new Runnable() {
            @Override
            public void run() {
                Looper.prepare();

                int i = 0;

                //if syncComplete is true already it means that we are not trying to sync, hence delay so that splash screen can close slowly
                if (syncComplete) {
                    try {
                        Thread.sleep(1000);
                    } catch (Exception e) {
                    }
                } else {
                    while (!syncComplete || i++ < 10) {
                        try {
                            Thread.sleep(1000);
                        } catch (Exception e) {
                            break;
                        }
                    }

                    //make sure background task is completed.  If not, force it closed
                    if (!syncComplete) {
                        try {
                            if (syncdb.getStatus() != AsyncTask.Status.FINISHED)
                                syncdb.cancel(true);
                        } catch (Exception e) {
                        }
                    }
                }

                //After receiving first GPS Fix dismiss the Progress Dialog
                dialog.dismiss();

                //calling the tab class causes the current tab to be displayed (set to tab(0) which is the HomeScreen)

                Intent intent = new Intent();
                intent.setClass(SplashScreen.this, HomeScreen.class);
                startActivity(intent);

                //transition from splash to main menu is slowed down to a fade by this command
                overridePendingTransition(R.anim.activityfadein, R.anim.splashfadeout);

                SplashScreen.this.finish();
            }
        };

        // Create a Dialog to let the User know that we're waiting for a GPS Fix
        dialog = ProgressDialog.show(SplashScreen.this, "Please wait", "Initializing ...", true);

        Thread t = new Thread(showWaitDialog);
        t.start();
    }
}

From source file:com.nbplus.hybrid.BasicWebViewClient.java

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    // for excel download
    if (isDocumentMimeType(url)) {
        Log.d(TAG, "This url is document mimetype = " + url);
        if (StorageUtils.isExternalStorageWritable()) {
            Uri source = Uri.parse(url);

            // Make a new request pointing to the mp3 url
            DownloadManager.Request request = new DownloadManager.Request(source);
            // Use the same file name for the destination
            File destinationFile = new File(
                    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
                    source.getLastPathSegment());
            request.setDestinationUri(Uri.fromFile(destinationFile));
            // Add it to the manager
            mDownloadManager.enqueue(request);
            Toast.makeText(mContext, R.string.downloads_requested, Toast.LENGTH_SHORT).show();
        } else {/*  w  w w . ja  v  a 2 s .  c om*/
            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setPositiveButton("?", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    //closeWebApplication();
                }
            });
            builder.setMessage(R.string.downloads_path_check);
            builder.show();
        }
        return true;
    }

    if (url.startsWith("tel:")) {
        // phone call
        if (!PhoneState.hasPhoneCallAbility(mContext)) {
            Log.d(TAG, ">> This device has not phone call ability !!!");
            return true;
        }

        mContext.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
    } else if (url.startsWith("mailto:")) {
        url = url.replaceFirst("mailto:", "");
        url = url.trim();

        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[] { url });

        mContext.startActivity(i);
    } else if (url.startsWith("geo:")) {
        Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        mContext.startActivity(searchAddress);
    } else {
        //  URL ??   ? ??? .
        dismissProgressDialog();
        loadWebUrl(url);
        showProgressDialog();
    }
    return true;
}

From source file:com.spoiledmilk.ibikecph.favorites.EditFavoriteFragment.java

private void launchErrorDialog(final String msg) {
    if (getActivity() != null && getView() != null) {
        getActivity().runOnUiThread(new Runnable() {

            @Override/*from   ww w.  j av  a2s. co  m*/
            public void run() {
                getView().findViewById(R.id.progress).setVisibility(View.INVISIBLE);
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle("Error");
                builder.setMessage(msg);
                builder.setPositiveButton(IbikeApplication.getString("ok"),
                        new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();

                            }
                        });
                dialog2 = builder.show();
            }
        });
    }

}