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:jieehd.villain.updater.VillainUpdater.java

private boolean haveNetworkConnection() {
    boolean haveConnectedWifi = false;
    boolean haveConnectedMobile = false;

    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
    for (NetworkInfo ni : netInfo) {
        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
            if (ni.isConnected())
                haveConnectedWifi = true;
        if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
            if (ni.isConnected())
                haveConnectedMobile = true;

    }//from  ww  w.  j  a  v  a 2s. c  om
    if (haveConnectedWifi == false && haveConnectedMobile == false) {
        Log.d("Network State", "false");
        AlertDialog.Builder alert = new AlertDialog.Builder(VillainUpdater.this);
        alert.setTitle("No Data Connection!");
        alert.setMessage(
                "You have no data connection, click ok to turn on WiFi or Mobile Data in order to check for OTA updates.");
        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int whichButton) {
                // TODO Auto-generated method stub
                final Intent intent = new Intent(Intent.ACTION_MAIN, null);
                intent.addCategory(Intent.CATEGORY_LAUNCHER);
                final ComponentName cn = new ComponentName("com.android.settings",
                        "com.android.settings.wifi.WifiSettings");
                intent.setComponent(cn);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }

        });
        alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                return;
            }
        });
        alert.show();

    } else {
        download();
    }
    return haveConnectedWifi || haveConnectedMobile;
}

From source file:jp.co.rakuten.rakutenvideoplayer.base.BaseActivity.java

/**
 * Show dialog error// www  .jav a  2s .  com
 * @param errStr
 */
public void showDialogError(String errStr) {
    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setIcon(R.drawable.icon);
    adb.setTitle(R.string.str_ErrPlay_Title);
    adb.setMessage(errStr);
    adb.setPositiveButton(R.string.str_OK, new OnClickListener() {
        public void onClick(DialogInterface a0, int a1) {
            finish();
        }
    });
    adb.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {

            if (keyCode == KeyEvent.KEYCODE_BACK) {
                dialog.dismiss();
                finish();

                return true;
            }

            return false;
        }

    });

    AlertDialog ad = adb.create();
    ad.show();
}

From source file:com.webileapps.fragments.CordovaFragment.java

/**
 * Display an error dialog and optionally exit application.
 *///w  ww. j av  a2s .  com
public void displayError(final String title, final String message, final String button, final boolean exit) {
    final CordovaFragment me = this;
    me.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            try {
                AlertDialog.Builder dlg = new AlertDialog.Builder(me.getActivity());
                dlg.setMessage(message);
                dlg.setTitle(title);
                dlg.setCancelable(false);
                dlg.setPositiveButton(button, new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        if (exit) {
                            getActivity().finish();
                        }
                    }
                });
                dlg.create();
                dlg.show();
            } catch (Exception e) {
                getActivity().finish();
            }
        }
    });
}

From source file:za.co.neilson.alarm.preferences.AlarmPreferencesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_item_save:
        Database.init(getApplicationContext());
        Database.setEmail(email);/*from w ww . j a v  a2s.  c o m*/

        if (getMathAlarm().getId() < 1) {
            getMathAlarm().setEmail(email);
            Database.create(getMathAlarm());
            Bundle bundle = getIntent().getExtras();
            if (bundle != null && bundle.containsKey("user")) {
                User user = (User) bundle.getSerializable("user");
                Group group = new Group(getMathAlarm(), user);
                Database.addGroup(group);
            }
            params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("email", email));
            Log.d("??? ? : ", "" + email);
            params.add(new BasicNameValuePair("time", getMathAlarm().getAlarmTimeString()));
            params.add(new BasicNameValuePair("difficulty",
                    Integer.toString(getMathAlarm().getDifficulty().ordinal())));
            params.add(new BasicNameValuePair("tone", getMathAlarm().getAlarmTonePath()));
            params.add(new BasicNameValuePair("vibrate", Boolean.toString(getMathAlarm().getVibrate())));
            params.add(new BasicNameValuePair("name", getMathAlarm().getAlarmName()));
            //params.add(new BasicNameValuePair("days", Arrays.toString(getMathAlarm().getDays())));
            for (int i = 0; i < getMathAlarm().getDays().length; i++) {
                params.add(new BasicNameValuePair("days", getMathAlarm().getDays()[i].toString()));
            }
            ServerRequest sr = new ServerRequest();
            JSONObject json = sr.getJSON("http://168.188.123.218:8080/alarmdata", params);
            if (json != null) {
                try {
                    String jsonstr = json.getString("response");
                    //JSONObject json2 = sr.getJSON("http://168.188.123.218:8080/useralarm", params);

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

        } else {
            Database.update(getMathAlarm());
            Database.setEmail(email);

        }

        callMathAlarmScheduleService();
        Toast.makeText(AlarmPreferencesActivity.this, getMathAlarm().getTimeUntilNextAlarmMessage(),
                Toast.LENGTH_LONG).show();
        finish();
        break;
    case R.id.menu_item_delete:
        AlertDialog.Builder dialog = new AlertDialog.Builder(AlarmPreferencesActivity.this);
        dialog.setTitle("Delete");
        dialog.setMessage("Delete this alarm?");
        dialog.setPositiveButton("Ok", new OnClickListener() {

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

                Database.init(getApplicationContext());
                Database.setEmail(email);

                if (getMathAlarm().getId() < 1) {
                    // Alarm not saved
                } else {
                    params = new ArrayList<NameValuePair>();
                    params.add(new BasicNameValuePair("email", email));
                    params.add(new BasicNameValuePair("time", alarm.getAlarmTimeString()));
                    Log.d("??? ? : ", "" + email);
                    ServerRequest sr = new ServerRequest();
                    JSONObject json = sr.getJSON("http://168.188.123.218:8080/deletealarm", params);

                    Database.deleteEntry(alarm);
                    callMathAlarmScheduleService();
                }
                finish();
            }
        });
        dialog.setNegativeButton("Cancel", new OnClickListener() {

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

        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.sourcey.materiallogindemo.MainActivity.java

private void DialogMap() {
    View dialogBoxView = View.inflate(this, R.layout.activity_map, null);
    final WebView map = (WebView) dialogBoxView.findViewById(R.id.webView);

    String url = getString(R.string.url_map) + "index.php?poinFrom=" + txtStart.getText().toString().trim()
            + "&poinTo=" + txtEnd.getText().toString().trim();

    map.getSettings().setLoadsImagesAutomatically(true);
    map.getSettings().setJavaScriptEnabled(true);
    map.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    map.loadUrl(url);/*from   w  w w .ja va  2s .  c  o  m*/

    AlertDialog.Builder builderInOut = new AlertDialog.Builder(this);
    builderInOut.setTitle("Map");
    builderInOut.setMessage("").setView(dialogBoxView).setCancelable(false)
            .setPositiveButton("Close", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).show();
}

From source file:fr.pasteque.client.Configure.java

/**
 * Display an AlertDialog/*  w w  w . jav a2  s.c  om*/
 * Based on Error.showError() but Configuration is not a TrackedActivity
 *
 * @param message to display
 */
private void showError(String message) {
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle(R.string.error_title);
    b.setMessage(message);
    b.setIcon(android.R.drawable.ic_dialog_alert);
    b.setCancelable(true);
    b.setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Configure.this.invalidateError();
        }
    });
    b.show();
}

From source file:org.yaoha.YaohaActivity.java

private void openFavMenu(final ImageButton btn, final TextView tv) {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    final EditText input = new EditText(this);
    alert.setTitle("Adding favorite");
    alert.setMessage("Enter your favorite search");
    alert.setView(input);//  w w w  .j av  a 2 s .c o m

    alert.setPositiveButton("Set", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            final Editor edit = prefs.edit();
            String tmp = "";
            tv.setText(input.getText());
            btn.setImageResource(R.drawable.placeholder_logo);
            if (btn.getId() == button_favorite_1.getId()) {
                tmp = "saved_fav_1_text";
            } else if (btn.getId() == button_favorite_2.getId()) {
                tmp = "saved_fav_2_text";
            } else if (btn.getId() == button_favorite_3.getId()) {
                tmp = "saved_fav_3_text";
            } else if (btn.getId() == button_favorite_4.getId()) {
                tmp = "saved_fav_4_text";
            } else if (btn.getId() == button_favorite_5.getId()) {
                tmp = "saved_fav_5_text";
            } else if (btn.getId() == button_favorite_6.getId()) {
                tmp = "saved_fav_6_text";
            }
            edit.putString(tmp, input.getText().toString());
            edit.commit();
            //TODO add method to catch pre-defined store-icons
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            // Canceled. 
        }
    });
    alert.show();
}

From source file:com.dnielfe.manager.dialogs.FilePropertiesDialog.java

@Override
public Dialog onCreateDialog(Bundle state) {
    activity = getActivity();//from   w  w w.  j  a v a  2 s  .co  m
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    mAdapter = new PropertiesAdapter(activity, mFile);
    builder.setTitle(mFile.getName());
    builder.setNeutralButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final FilePermissionsPagerItem fragment = (FilePermissionsPagerItem) mAdapter.getItem(1);
            fragment.applyPermissions(getActivity());
        }
    });
    final View content = activity.getLayoutInflater().inflate(R.layout.dialog_properties_container, null);
    this.initView(content);
    builder.setView(content);
    final AlertDialog dialog = builder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(final DialogInterface dialog) {
            ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE).setVisibility(View.GONE);
        }
    });
    return dialog;
}

From source file:com.linkbubble.util.YouTubeEmbedHelper.java

AlertDialog getEmbedResultsDialog() {
    if (mEmbedInfo.size() > 0) {
        ListView listView = new ListView(mContext);
        listView.setAdapter(new EmbedItemAdapter());

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setView(listView);/*from www.j a v a2  s  .co m*/
        builder.setIcon(mYouTubeResolveInfo.loadIcon(mContext.getPackageManager()));
        builder.setTitle(R.string.title_youtube_embed_to_load);

        final AlertDialog alertDialog = builder.create();
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                EmbedInfo embedInfo = (EmbedInfo) view.getTag();
                if (embedInfo != null) {
                    loadYouTubeVideo(embedInfo.mId);
                }
                alertDialog.dismiss();
            }
        });

        return alertDialog;
    } else {
        final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
        alertDialog.setTitle(R.string.youtube_embed_error_title);
        alertDialog.setMessage(mContext.getString(R.string.youtube_embed_error_summary));
        alertDialog.setButton(AlertDialog.BUTTON_POSITIVE,
                mContext.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() {

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

                });
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        return alertDialog;
    }
}

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

private void boardUploader(final InternetFullBoard board, final int phpOperation) {
    LayoutInflater inflater = (LayoutInflater) Uploads.this.getSystemService(LAYOUT_INFLATER_SERVICE);
    final View layout = inflater.inflate(R.layout.internet_uploads_alert_upload_board,
            (ViewGroup) findViewById(R.id.alert_settings_root));

    TextView wikiLink = (TextView) layout.findViewById(R.id.wikiLink);
    wikiLink.setText("\n  Guide here!\n\n");

    wikiLink.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/Mikuz/Boarder/wiki/Uploading-guide"));
            startActivity(browserIntent);
        }/* w ww .  ja  v a 2s  . c  om*/
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(Uploads.this);
    builder.setView(layout);
    builder.setTitle("Upload board");

    refreshUploadAlertBoard(layout, board);

    final Button sendButton = (Button) layout.findViewById(R.id.sendButton);
    sendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mWaitDialog = new TimeoutProgressDialog(Uploads.this, "Waiting for response", TAG, false);
            HashMap<String, String> sendList = getSendList(layout, board, phpOperation);
            new ConnectionManager(Uploads.this, InternetMenu.mUploadBoardURL, sendList);
        }
    });

    final Button previewButton = (Button) layout.findViewById(R.id.previewButton);
    previewButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            HashMap<String, String> sendList = getSendList(layout, board, phpOperation);

            // Simulate a board from web
            sendList.put(InternetMenu.BOARD_ID_KEY, "-1");
            sendList.put(InternetMenu.RATING_KEY, "0");
            sendList.put(InternetMenu.USERNAME_KEY, "Preview");

            JSONObject databaseValues = new JSONObject();
            if (sendList != null) {
                for (String key : sendList.keySet()) {
                    try {
                        databaseValues.put(key, sendList.get(key));
                    } catch (JSONException e) {
                        Log.e(TAG, "Error putting '" + key + "' to JSONObject as database value");
                    }
                }
            }

            JSONArray jArray = new JSONArray();
            jArray.put(databaseValues);
            JSONObject fakeMessage = null;
            try {
                fakeMessage = new JSONObject();
                fakeMessage.put(ConnectionUtils.returnData, jArray);
            } catch (JSONException e) {
                Log.e(TAG, "Error constructing fake json message", e);
            }

            Intent i = new Intent(Uploads.this, DownloadBoard.class);
            XStream xstream = new XStream();
            i.putExtra(DownloadBoard.SHOW_KEY, DownloadBoard.SHOW_PREVIEW_BOARD);
            i.putExtra(DownloadBoard.JSON_KEY, xstream.toXML(fakeMessage));
            startActivity(i);
        }
    });

    builder.show();
}