Example usage for android.app AlertDialog.Builder setTitle

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

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * @see android.app.Activity#onCreateDialog(int)
 *//*from w  w w.j  a va 2 s.c o m*/
@Override
protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    switch (id) {
    case JSON_ERROR_DIALOG:
        builder.setTitle(R.string.cache_corrupt);
        builder.setMessage(R.string.cache_corrupt_message);
        builder.setNeutralButton(R.string.ok, new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        return builder.create();
    case NO_SERVER_DIALOG:
        builder.setTitle(R.string.no_servers);
        builder.setMessage(R.string.no_server_message);
        builder.setPositiveButton(R.string.yes, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent addServer = new Intent(MCServerTrackerActivity.this, AddServerActivity.class);
                startActivityForResult(addServer, AddServerActivity.ADD_SERVER_ACTIVITY_ID);
            }
        });
        builder.setNegativeButton(R.string.no, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        return builder.create();
    case IO_ERROR_DIALOG:
        break;
    }
    return super.onCreateDialog(id);
}

From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java

public void onWrongConnectionState(int state, final INotifiableManager manager, final Command<?> source) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    switch (state) {
    case WifiHelper.WIFI_STATE_DISABLED:
        builder.setTitle("Wifi disabled");
        builder.setMessage("This host is Wifi only. Should I activate Wifi?");
        builder.setNeutralButton("Activate Wifi", new OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                final ProgressDialog pd = new ProgressDialog(mActivity);
                pd.setCancelable(true);//w w w  .ja  v  a  2 s .  co  m
                pd.setTitle("Activating Wifi");
                pd.setMessage("Please wait while Wifi is activated.");
                pd.show();
                (new Thread() {
                    public void run() {
                        final WifiHelper helper = WifiHelper.getInstance(mActivity);
                        helper.enableWifi(true);
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_ENABLED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        manager.retryAll();
                        pd.cancel();
                        mDialogShowing = false;

                    }
                }).start();
            }
        });
        showDialog(builder);
        break;
    case WifiHelper.WIFI_STATE_ENABLED:
        final Host host = HostFactory.host;
        final WifiHelper helper = WifiHelper.getInstance(mActivity);
        final String msg;
        if (host != null && host.access_point != null && !host.access_point.equals("")) {
            helper.connect(host);
            msg = "Connecting to " + host.access_point + ". Please wait";
        } else {
            msg = "Waiting for Wifi to connect to your LAN.";
        }
        final ProgressDialog pd = new ProgressDialog(mActivity);
        pd.setCancelable(true);
        pd.setTitle("Connecting");
        pd.setMessage(msg);
        mWaitForWifi = new Thread() {
            public void run() {
                mDialogShowing = true;
                pd.show();
                (new Thread() {
                    public void run() {
                        int wait = 0;
                        while (wait <= MAX_WAIT_FOR_WIFI * 1000
                                && helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            try {
                                sleep(500);
                                wait += 500;
                            } catch (InterruptedException e) {
                            }
                        }
                        pd.cancel();
                        mDialogShowing = false;
                    }
                }).start();
                pd.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(DialogInterface dialog) {
                        if (helper.getWifiState() != WifiHelper.WIFI_STATE_CONNECTED) {
                            builder.setTitle("Wifi doesn't seem to connect");
                            builder.setMessage(
                                    "You can open the Wifi settings or wait " + MAX_WAIT_FOR_WIFI + " seconds");
                            builder.setNeutralButton("Wifi Settings", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
                                }
                            });
                            builder.setCancelable(true);
                            builder.setNegativeButton("Wait", new OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    mDialogShowing = false;
                                    mActivity.runOnUiThread(mWaitForWifi); //had to make the Thread a field because of this line
                                }
                            });

                            mActivity.runOnUiThread(new Runnable() {
                                public void run() {
                                    final AlertDialog alert = builder.create();
                                    try {
                                        if (!mDialogShowing) {
                                            alert.show();
                                            mDialogShowing = true;
                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            });
                        }
                    }

                });
            }
        };
        mActivity.runOnUiThread(mWaitForWifi);
    }

}

From source file:net.evecom.android.log.DailyLogAddActivity.java

/**
 * /*w  w  w .  j av a 2s  . c  o  m*/
 */
private String submit() {
    /**  */
    if (btEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (sswgButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rzlxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (gzsjButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rznrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years > calendar.get(Calendar.YEAR)) {
        DialogToast("");
        return "";
    } else if (years == calendar.get(Calendar.YEAR)) {
        if (month > calendar.get(Calendar.MONTH) + 1) {
            DialogToast("");
            return "";
        } else if (month == calendar.get(Calendar.MONTH) + 1) {
            if (day > calendar.get(Calendar.DAY_OF_MONTH)) {
                DialogToast("");
                return "";
            }
        }
    }

    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogAddActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogAddActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
    return "1";
}

From source file:org.ambientdynamix.core.HomeActivity.java

private void updateCheck() {
    new Thread(new Runnable() {
        @Override/*from   w  ww.  j  a va2s. c  om*/
        public void run() {
            try {
                PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
                int verCode = pInfo.versionCode;
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet("http://repo.smartphone-experimentation.eu/app/");
                try {
                    HttpResponse execute = client.execute(httpGet);
                    InputStream content = execute.getEntity().getContent();

                    BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
                    StringBuilder builder = new StringBuilder();
                    String s = "";
                    while ((s = buffer.readLine()) != null) {
                        builder.append(s);
                    }

                    try {
                        if (verCode != Integer.parseInt(builder.toString())) {
                            {
                                final AlertDialog.Builder alertBuilder = new AlertDialog.Builder(activity);
                                alertBuilder.setTitle("Update Available");
                                alertBuilder.setMessage(
                                        "There is a newer version available for Organicity Experimentation. "
                                                + "Please click 'Update' to download and install the latest version.");
                                alertBuilder.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        Intent browserIntent = new Intent(Intent.ACTION_DEFAULT, Uri.parse(
                                                "http://repo.smartphone-experimentation.eu/app/dynamix-framework-debug.apk"));
                                        startActivity(browserIntent);
                                    }
                                });
                                alertBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        // User cancelled the dialog
                                    }
                                });
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        alertBuilder.show();
                                    }
                                });
                            }
                        }
                    } catch (Exception ignore) {
                    }
                } catch (Exception ignore) {
                }
            } catch (PackageManager.NameNotFoundException e) {
            }
        }
    }).start();
}

From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java

private void showUploadPhotoPopup(final boolean isFinishingService) {
    AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
    adb.setTitle("Adjuntar imagen");
    adb.setMessage("Desea adjuntar una imagen al incidente?");
    adb.setPositiveButton("Si", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dispatchTakePictureIntent(isFinishingService);
        }/*from  www  . ja v a 2s. c o m*/
    });
    adb.setNegativeButton("No", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (isFinishingService) {
                finishIncident();
            }
            dialog.cancel();
        }
    });

    adb.show();
}

From source file:fi.mikuz.boarder.gui.internet.Uploads.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    final InternetFullBoard board = ((BoardListAdapter) mListView.getAdapter()).getItem(position);

    if (!board.getUploaderUsername().equals("")) {
        final CharSequence[] items = { "Edit", "Delete" };

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(board.getBoardName());
        builder.setItems(items, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                if (item == 0) {
                    boardUploader(board, InternetMenu.PHP_OPERATION_EDIT);
                } else if (item == 1) {
                    AlertDialog.Builder deleteBuilder = new AlertDialog.Builder(Uploads.this);
                    deleteBuilder.setTitle("Deleting upload");
                    deleteBuilder.setMessage("Are you sure you want to permanently delete upload '"
                            + board.getBoardName() + "'?");

                    deleteBuilder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            HashMap<String, String> sendList = new HashMap<String, String>();
                            sendList.put(InternetMenu.UPLOADER_ID_KEY, mUserId);
                            sendList.put(InternetMenu.SESSION_TOKEN_KEY, mSessionToken);
                            sendList.put(InternetMenu.BOARD_ID_KEY, Integer.toString(board.getBoardId()));
                            new ConnectionManager(Uploads.this, InternetMenu.mDeleteUploadedBoardURL, sendList);
                        }//from  ww w  . j av a 2s.com
                    });
                    deleteBuilder.setNegativeButton("No", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.dismiss();
                        }
                    });
                    AlertDialog deleteAlert = deleteBuilder.create();
                    deleteAlert.show();
                }
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:edu.missouri.bas.activities.AdminManageActivity.java

private Dialog buildDialog2(Context context, String str) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*from   w  ww. j  a  v a2s . c o  m*/
    builder.setTitle("Confirm");
    builder.setMessage(str);
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            editor.putString(ASID, asID.getText().toString());
            Log.d("here!!!", "id is " + asID.getText().toString());
            //format check

            editor.putString(ASPWD, "");
            editor.commit();
            setHints();
            setResult(8);
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            setHints();
        }
    });
    return builder.create();
}

From source file:com.zira.registration.DocumentUploadActivity.java

@Override
public void processFinish(String output, String methodName) {
    // obj;//from  ww  w .  j  ava  2 s.  co m
    //Log.e("doucment", output);
    if (methodName.equalsIgnoreCase(uploadImageMethod)) {
        Log.e("doucment", output);
        /*try {
           //JSONObject   obj = new JSONObject(output);
        //   String jsonMessage=obj.getString("message");
           //String jsonMessage1=obj.getString("result");
        //   System.err.println("messgage=="+jsonMessage+"result="+jsonMessage1);
        } catch (JSONException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }*/
    }
    if (methodName.equalsIgnoreCase(driverRegMethod)) {
        Log.e("driver update", output);
        try {
            JSONObject obj = new JSONObject(output);
            String jsonResult = obj.getString("result");
            String jsonMessage = obj.getString("message");

            if (jsonResult.equals("0")) {
                //Util.alertMessage(DocumentUploadActivity.this, jsonMessage);
                //editor.clear();
                //editor.commit();
                AlertDialog.Builder alert = new AlertDialog.Builder(DocumentUploadActivity.this);
                alert.setTitle("Zira24/7");
                alert.setMessage("Registration successful");

                alert.setPositiveButton("ok", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        //System.err.println("messgage=="+jsonMessage+" "+jsonResult);
                        //            Toast.makeText(DocumentUploadActivity.this, jsonMessage, 1).show();
                        SingleTon.getInstance().setEdited(false);
                        mProfileInfoModel.setVechile_make(SingleTon.getInstance().getVehicleMake());
                        mProfileInfoModel.setVechile_model(SingleTon.getInstance().getVehicleModel());
                        mProfileInfoModel.setVechile_year(SingleTon.getInstance().getVehicleYear());
                        mProfileInfoModel
                                .setLicenseplatenumber(SingleTon.getInstance().getVehicleLicencePlateNumber());
                        mProfileInfoModel
                                .setLicenseplatecountry(SingleTon.getInstance().getVehicleCountryName());
                        mProfileInfoModel.setLicenseplatestate(SingleTon.getInstance().getVehicleStateName());
                        mProfileInfoModel.setAddress(SingleTon.getInstance().getBg_address1() + "");
                        mProfileInfoModel.setAddress1(SingleTon.getInstance().getBg_address1());
                        mProfileInfoModel.setAddress2("");//SingleTon.getInstance().getBg_address2());
                        mProfileInfoModel.setCity(SingleTon.getInstance().getBg_city());
                        mProfileInfoModel.setState(SingleTon.getInstance().getBg_drivingLicenseState());
                        mProfileInfoModel.setZipcode(SingleTon.getInstance().getBg_zipcode());
                        mProfileInfoModel
                                .setDrivinglicensenumber(SingleTon.getInstance().getBg_drivingLicenseNumber());
                        mProfileInfoModel
                                .setDrivinglicensestate(SingleTon.getInstance().getBg_drivingLicenseState());
                        mProfileInfoModel
                                .setDrivinglicenseexpirationdate(SingleTon.getInstance().getBg_LicExoDate());
                        mProfileInfoModel.setDateofbirth(SingleTon.getInstance().getBgDOB());
                        mProfileInfoModel
                                .setSocialsecuritynumber(SingleTon.getInstance().getBg_socialSecNumber());
                        SingleTon.getInstance().setProfileInfoModel(mProfileInfoModel);
                        getProfileInfo();
                        //finish();
                    }
                });
                alert.show();

                /*if(prefs.getString("mode", "").equals("rider"))
                {
                Intent i=new Intent(DocumentUploadActivity.this,VehicleSearchActivity.class);
                finish();
                startActivity(i);
                }
                else if(prefs.getString("mode", "").equals("driver"))
                {
                //Intent i=new Intent(DocumentUploadActivity.this,DriverModeActivity.class);
                finish();
                //startActivity(i);
                }*/

            } else {
                Util.alertMessage(DocumentUploadActivity.this, jsonMessage);
            }

        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
    if (methodName.equalsIgnoreCase(GetProfile)) {
        Log.e("getprofile=", output);
        mProfileInfoModel = ziraParser.profileInfo(output);
        SingleTon.getInstance().setProfileInfoModel(mProfileInfoModel);
        Intent i = new Intent(DocumentUploadActivity.this, GetProfile.class);
        startActivity(i);
        finish();

    }
}

From source file:com.microsoft.o365_android_onenote_rest.SnippetDetailFragment.java

@Override
public void onError(Exception e) {
    if (!isAdded()) {
        return;/*w w  w.  j a v  a2s. c o m*/
    }
    displayThrowable(e);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.token_err_title).setMessage(R.string.token_err_msg)
            .setPositiveButton(R.string.dismiss, null)
            .setNegativeButton(R.string.disconnect, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mAuthenticationManager.disconnect();
                }
            }).show();
}

From source file:com.zlkj.dingdangwuyou.activity.CompanyInfoActivity.java

/**
 * ?//from   www.  j a  va 2 s .  c o  m
 */
private void showAvatarOption() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    String[] items = new String[] { "?", "" };
    builder.setTitle("").setItems(items, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent();
            switch (which) {
            case 0: // ?
                if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
                    String curTime = AppTool.dateFormat(System.currentTimeMillis(), "yyyyMMddHHmmss");
                    // ???
                    File imagePath = new File(Environment.getExternalStorageDirectory() + Const.APP_IMAGE_PATH);
                    if (!imagePath.exists()) {
                        imagePath.mkdirs();
                    }
                    cameraFile = new File(imagePath.getPath(), curTime + ".jpg");

                    intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile));
                    startActivityForResult(intent, Const.REQUEST_CODE_CAMERA);

                } else {
                    Toast.makeText(context, "???", Toast.LENGTH_SHORT)
                            .show();
                }
                break;

            case 1: // 
                intent.setAction(Intent.ACTION_PICK);
                intent.setType("image/*");
                startActivityForResult(intent, Const.REQUEST_CODE_GALLERY);
                break;

            default:
                break;
            }
        }
    });

    builder.show();
}