Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:com.android.quake.llvm.DownloaderActivity.java

private void onDownloadFailed(String reason) {
    Log.e(LOG_TAG, "Download stopped: " + reason);
    String shortReason;//from  w w w  .  ja va 2  s .  c  om
    int index = reason.indexOf('\n');
    if (index >= 0) {
        shortReason = reason.substring(0, index);
    } else {
        shortReason = reason;
    }
    AlertDialog alert = new Builder(this).create();
    alert.setTitle(R.string.download_activity_download_stopped);

    if (!mSuppressErrorMessages) {
        alert.setMessage(shortReason);
    }

    alert.setButton(getString(R.string.download_activity_retry), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            startDownloadThread();
        }

    });
    alert.setButton2(getString(R.string.download_activity_quit), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            finish();
        }

    });
    try {
        alert.show();
    } catch (WindowManager.BadTokenException e) {
        // Happens when the Back button is used to exit the activity.
        // ignore.
    }
}

From source file:bikebadger.RideFragment.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case MY_DATA_CHECK_CODE_REQUEST:
        // for testing
        //resultCode = TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL;
        switch (resultCode) {
        case TextToSpeech.Engine.CHECK_VOICE_DATA_PASS:
            RideManager.mTTS = new TextToSpeech(mRideManager.mAppContext, this);
            //RideManager.mTTS = null;
            Log.v(Constants.APP.TAG, "TextToSpeech installed");
            break;
        case TextToSpeech.Engine.CHECK_VOICE_DATA_BAD_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_DATA:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_MISSING_VOLUME:
        case TextToSpeech.Engine.CHECK_VOICE_DATA_FAIL:

            Log.e(Constants.APP.TAG, "Got a failure. Text To Speech not available");

            AlertDialog ad = new AlertDialog.Builder(getActivity()).create();
            ad.setCancelable(false);/*  w ww .j a  v a 2 s  .co m*/
            ad.setTitle("Text To Speech Engine Not Found");
            ad.setMessage(
                    "There was a problem finding the Text To Speech Engine. Make sure it's install properly under Language and Input Settings.");
            ad.setButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            ad.show();

            // missing data, install it
            //Log.v(Constants.APP.TAG, "Need language stuff: " + resultCode);
            //Intent installIntent = new Intent();
            //installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            //startActivity(installIntent);
            break;
        }

        break;
    /* No longer used as it is deprecated. Use SimpleFileDialog instead even though it blocks.
    TODO - integrate a slick open file that includes DropBox and Drive library!
    case Constants.APP.FILE_CHOOSER_REQUEST_CODE:
            
        if (resultCode == getActivity().RESULT_OK) {
            if (data != null) {
                // Get the URI of the selected file
                final Uri uri = data.getData();
                Log.i(Constants.APP.TAG, "Uri = " + uri.toString());
                try {
                    // Get the file path from the URI
                    final String path = FileUtils.getPath(mRideManager.mAppContext, uri);
                    //Toast.makeText(getActivity(), "File Selected: " + path, Toast.LENGTH_LONG).show();
                    OpenGPXFileOnNewThreadWithDialog(path);
                   // if(isVisible())
                     //    updateUI(); // update title bar file loaded
                } catch (Exception e) {
                    Log.e("FileSelectorTestActivity", "File select error", e);
                }
            }
        }
        break;
         */
    case Constants.APP.ACTION_WAYPOINT_REQUEST_CODE:
        if (resultCode == getActivity().RESULT_OK) {
            if (data != null) {
                final Location location = data.getParcelableExtra("location");
                String command = data.getStringExtra("command");
                final String arg = data.getStringExtra("argument");

                mRideManager.AddNewWaypoint(command, arg, location);
                // enable the save menu
                mMenu.findItem(R.id.menu_item_gpx_save).setEnabled(true);
            }
        }
        break;
    case MY_MAP_CODE_REQUEST:

        if (resultCode == getActivity().RESULT_OK) {
            Log.d(Constants.APP.TAG, "Return from map");
        }
        break;
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.odk.collect.android.activities.GoogleDriveActivity.java

private void createAlertDialog(String message) {
    Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "show");

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(getString(R.string.download_forms_result));
    alertDialog.setMessage(message);/*w  w w.  j  a va2s.  c o  m*/
    DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON1: // ok
                Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "OK");
                alertShowing = false;
                finish();
                break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), quitListener);
    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertShowing = true;
    alertMsg = message;
    alertDialog.show();
}

From source file:org.openremote.android.console.AppSettingsActivity.java

@Override
public void urlConnectionDidReceiveResponse(HttpResponse httpResponse) {
    int statusCode = httpResponse.getStatusLine().getStatusCode();
    if (statusCode != Constants.HTTP_SUCCESS) {
        loadingPanelProgress.dismiss();/*  w w  w.j a  va  2 s .  c o  m*/
        if (statusCode == ControllerException.UNAUTHORIZED) {
            LoginDialog loginDialog = new LoginDialog(this);
            loginDialog.setOnClickListener(loginDialog.new OnloginClickListener() {
                @Override
                public void onClick(View v) {
                    super.onClick(v);
                    requestPanelList();
                    checkAuthentication();
                    requestAccess();
                }

            });
        } else {
            // The following code customizes the dialog, because the finish method should do after dialog show and click ok.
            AlertDialog alertDialog = new AlertDialog.Builder(this).create();
            alertDialog.setTitle("Panel List Not Found");
            alertDialog.setMessage(ControllerException.exceptionMessageOfCode(statusCode));
            alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alertDialog.show();
        }
    }

}

From source file:id.ridon.keude.views.ManageReposActivity.java

private void scanForRepos() {
    final RepoScanListAdapter adapter = new RepoScanListAdapter(this);
    final MDnsHelper mDnsHelper = new MDnsHelper(this, adapter);

    final View view = getLayoutInflater().inflate(R.layout.repodiscoverylist, null);
    final ListView repoScanList = (ListView) view.findViewById(R.id.reposcanlist);

    final AlertDialog alrt = new AlertDialog.Builder(this).setView(view)
            .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override//from   w  w  w.j  av  a 2 s .  co m
                public void onClick(DialogInterface dialog, int which) {
                    mDnsHelper.stopDiscovery();
                    dialog.dismiss();
                }
            }).create();

    alrt.setTitle(R.string.local_repos_title);
    alrt.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mDnsHelper.stopDiscovery();
        }
    });

    repoScanList.setAdapter(adapter);
    repoScanList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {

            final DiscoveredRepo discoveredService = (DiscoveredRepo) parent.getItemAtPosition(position);

            final ServiceInfo serviceInfo = discoveredService.getServiceInfo();
            String type = serviceInfo.getPropertyString("type");
            String protocol = type.contains("fdroidrepos") ? "https:/" : "http:/";
            String path = serviceInfo.getPropertyString("path");
            if (TextUtils.isEmpty(path))
                path = "/fdroid/repo";
            String serviceUrl = protocol + serviceInfo.getInetAddresses()[0] + ":" + serviceInfo.getPort()
                    + path;
            showAddRepo(serviceUrl, serviceInfo.getPropertyString("fingerprint"));
        }
    });

    alrt.show();
    mDnsHelper.discoverServices();
}

From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java

/**
 * ??Alter//from   w w  w .j av  a2  s  .c  om
 * 
 * @param message
 */
public void showAndroidAlert(final String title, final String message) {
    Runnable showAlert = new Runnable() {
        public void run() {
            final AlertDialog alert = new AlertDialog.Builder(LGameAndroid2DActivity.this).create();
            alert.setTitle(title);
            alert.setMessage(message);
            alert.setButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    alert.dismiss();
                }
            });
            alert.show();
        }
    };
    runOnUiThread(showAlert);
}

From source file:au.com.wallaceit.reddinator.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = MainActivity.this;
    global = ((GlobalObjects) context.getApplicationContext());
    prefs = PreferenceManager.getDefaultSharedPreferences(context);
    setContentView(R.layout.activity_main);
    // Setup actionbar
    appView = findViewById(R.id.appview);
    actionBar = getActionBar();//from w  ww . j a va2 s . com
    if (actionBar != null) {
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setCustomView(R.layout.appheader);
    }
    // get actionBar Views
    loader = (ProgressBar) findViewById(R.id.appsrloader);
    errorIcon = (ImageView) findViewById(R.id.apperroricon);
    refreshbutton = (ImageButton) findViewById(R.id.apprefreshbutton);
    configbutton = (ImageButton) findViewById(R.id.appprefsbutton);
    srtext = (TextView) findViewById(R.id.appsubreddittxt);

    // set theme colors
    setThemeColors();

    // setup button onclicks
    refreshbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            listAdapter.reloadReddits();
        }
    });

    View.OnClickListener srclick = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent srintent = new Intent(context, SubredditSelectActivity.class);
            startActivityForResult(srintent, 0);
        }
    };

    View.OnClickListener configclick = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent prefsintent = new Intent(context, PrefsActivity.class);
            prefsintent.putExtra("fromapp", true);
            startActivityForResult(prefsintent, 0);
        }
    };

    srtext.setOnClickListener(srclick);
    configbutton.setOnClickListener(configclick);
    findViewById(R.id.app_logo).setOnClickListener(srclick);

    // Setup list adapter
    listView = (ListView) findViewById(R.id.applistview);
    listAdapter = new ReddinatorListAdapter(global, prefs);
    listView.setAdapter(listAdapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            openLink(position, 1);
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            final int position = i;
            AlertDialog linkDialog = new AlertDialog.Builder(context).create(); //Read Update
            linkDialog.setTitle("Open in browser");

            linkDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Comments",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            openLink(position, 3);
                        }
                    });

            linkDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "Content",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            openLink(position, 2);
                        }
                    });

            linkDialog.show();
            return true;
        }
    });

    // set the current subreddit
    srtext.setText(prefs.getString("currentfeed-app", "technology"));

    // Trigger reload?
    if (prefs.getBoolean("appreloadpref", false) || listAdapter.getCount() < 2)
        listAdapter.reloadReddits();

}

From source file:cm.aptoide.pt.ScheduledDownloads.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    Builder dialogBuilder = new AlertDialog.Builder(this);
    final AlertDialog scheduleDialog = dialogBuilder.create();

    //      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    switch (item.getItemId()) {
    case 0://  w w w.  j  av  a 2  s  .  c o m
        for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) {
            scheduledDownloadsHashMap.get(scheduledDownload).toggleChecked();
        }
        adapter.notifyDataSetInvalidated();
        break;
    case 1:
        if (isAllChecked()) {
            scheduleDialog.setTitle(getText(R.string.schDwnBtn));
            scheduleDialog.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
            scheduleDialog.setCancelable(false);
            scheduleDialog.setMessage(getText(R.string.schDown_sureremove));
            scheduleDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes),
                    new Dialog.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface arg0, int arg1) {
                            for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) {
                                if (scheduledDownloadsHashMap.get(scheduledDownload).checked) {
                                    db.deleteScheduledDownload(scheduledDownload);
                                }
                            }
                            getSupportLoaderManager().restartLoader(0, null, ScheduledDownloads.this);
                            return;
                        }
                    });
            scheduleDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no),
                    new Dialog.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int arg1) {
                            dialog.cancel();
                        }
                    });
            scheduleDialog.show();
        } else {
            Toast toast = Toast.makeText(this, getString(R.string.schDown_nodownloadselect),
                    Toast.LENGTH_SHORT);
            toast.show();
        }
        break;

    default:
        break;
    }
    return true;
}

From source file:fm.smart.r1.activity.ItemActivity.java

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // this should be called once image has been chosen by user
    // using requestCode to pass item id - haven't worked out any other way
    // to do it//from w  w  w.  ja  v  a 2 s .c om
    // if (requestCode == SELECT_IMAGE)
    if (resultCode == Activity.RESULT_OK) {
        // TODO check if user is logged in
        if (Main.isNotLoggedIn(this)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(this, LoginActivity.class.getName());
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            // avoid navigation back to this?
            LoginActivity.return_to = ItemActivity.class.getName();
            LoginActivity.params = new HashMap<String, String>();
            LoginActivity.params.put("item_id", (String) item.item_node.atts.get("id"));
            startActivity(intent);
            // TODO in this case forcing the user to rechoose the image
            // seems a little
            // rude - should probably auto-submit here ...
        } else {
            // Bundle extras = data.getExtras();
            // String sentence_id = (String) extras.get("sentence_id");
            final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
            myOtherProgressDialog.setTitle("Please Wait ...");
            myOtherProgressDialog.setMessage("Uploading image ...");
            myOtherProgressDialog.setIndeterminate(true);
            myOtherProgressDialog.setCancelable(true);

            final Thread add_image = new Thread() {
                public void run() {
                    // TODO needs to check for interruptibility

                    String sentence_id = Integer.toString(requestCode);
                    Uri selectedImage = data.getData();
                    // Bitmap bitmap = Media.getBitmap(getContentResolver(),
                    // selectedImage);
                    // ByteArrayOutputStream bytes = new
                    // ByteArrayOutputStream();
                    // bitmap.compress(Bitmap.CompressFormat.JPEG, 40,
                    // bytes);
                    // ByteArrayInputStream fileInputStream = new
                    // ByteArrayInputStream(
                    // bytes.toByteArray());

                    // TODO Might have to save to file system first to get
                    // this
                    // to work,
                    // argh!
                    // could think of it as saving to cache ...

                    // add image to sentence
                    FileInputStream is = null;
                    FileOutputStream os = null;
                    File file = null;
                    ContentResolver resolver = getContentResolver();
                    try {
                        Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage);
                        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
                        bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
                        // ByteArrayInputStream bais = new
                        // ByteArrayInputStream(bytes.toByteArray());

                        // FileDescriptor fd =
                        // resolver.openFileDescriptor(selectedImage,
                        // "r").getFileDescriptor();
                        // is = new FileInputStream(fd);

                        String filename = "test.jpg";
                        File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE);
                        file = new File(dir, filename);
                        os = new FileOutputStream(file);

                        // while (bais.available() > 0) {
                        // / os.write(bais.read());
                        // }
                        os.write(bytes.toByteArray());

                        os.close();

                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } finally {
                        if (os != null) {
                            try {
                                os.close();
                            } catch (IOException e) {
                            }
                        }
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e) {
                            }
                        }
                    }

                    // File file = new
                    // File(Uri.decode(selectedImage.toString()));

                    // ensure item is in users default list

                    ItemActivity.add_item_result = addItemToList(Main.default_study_list_id,
                            (String) item.item_node.atts.get("id"), ItemActivity.this);
                    Result result = ItemActivity.add_item_result;

                    if (ItemActivity.add_item_result.success()
                            || ItemActivity.add_item_result.alreadyInList()) {

                        // ensure sentence is in users default list

                        ItemActivity.add_sentence_list_result = addSentenceToList(sentence_id,
                                (String) item.item_node.atts.get("id"), Main.default_study_list_id,
                                ItemActivity.this);
                        result = ItemActivity.add_sentence_list_result;
                        if (ItemActivity.add_sentence_list_result.success()) {

                            String media_entity = "http://test.com/test.jpg";
                            String author = "tansaku";
                            String author_url = "http://smart.fm/users/tansaku";
                            Log.d("DEBUG-IMAGE-URI", selectedImage.toString());
                            ItemActivity.add_image_result = addImage(file, media_entity, author, author_url,
                                    "1", sentence_id, (String) item.item_node.atts.get("id"),
                                    Main.default_study_list_id);
                            result = ItemActivity.add_image_result;
                        }
                    }
                    final Result display = result;
                    myOtherProgressDialog.dismiss();
                    ItemActivity.this.runOnUiThread(new Thread() {
                        public void run() {
                            final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                            dialog.setTitle(display.getTitle());
                            dialog.setMessage(display.getMessage());
                            dialog.setButton("OK", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    if (ItemActivity.add_image_result != null
                                            && ItemActivity.add_image_result.success()) {
                                        ItemListActivity.loadItem(ItemActivity.this,
                                                item.item_node.atts.get("id").toString());
                                    }
                                }
                            });

                            dialog.show();
                        }
                    });

                }

            };

            myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    add_image.interrupt();
                }
            });
            OnCancelListener ocl = new OnCancelListener() {
                public void onCancel(DialogInterface arg0) {
                    add_image.interrupt();
                }
            };
            myOtherProgressDialog.setOnCancelListener(ocl);
            closeMenu();
            myOtherProgressDialog.show();
            add_image.start();

        }
    }
}

From source file:org.trosnoth.serveradmin.GameStateActivity.java

protected Dialog onCreateDialog(int id) {
    if (id == 1001) {
        AlertDialog.Builder builder;// w ww. jav a2 s  . co m
        AlertDialog alertDialog;

        Context mContext = GameStateActivity.this;
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.time_dialog, (ViewGroup) findViewById(R.id.layout_root));

        final EditText secs = (EditText) layout.findViewById(R.id.editSeconds);
        secs.setFilters(InputFilters.integerFilter(59));

        final EditText mins = (EditText) layout.findViewById(R.id.editMinutes);

        builder = new AlertDialog.Builder(mContext);
        builder.setView(layout);
        alertDialog = builder.create();
        alertDialog.setTitle(R.string.game_state_adjust_time);
        alertDialog.setButton(-1, getApplicationContext().getString(R.string.save),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {

                        // Get the values from the EditTexts in the dialog
                        String minStr = mins.getText().toString();
                        String secStr = secs.getText().toString();

                        // Convert the minute value
                        int minInt;
                        if (minStr.length() == 0) {
                            minInt = 0;
                        } else {
                            minInt = Integer.valueOf(minStr);
                        }

                        // Convert the second value
                        int secInt;
                        if (secStr.length() == 0) {
                            secInt = 0;
                        } else {
                            secInt = Integer.valueOf(secStr);
                        }

                        // Send it through to the server
                        int totalSeconds = minInt * 60 + secInt;

                        Log.i(LOGTAG, "Adjusting time remaining: " + totalSeconds);
                        if (totalSeconds > 0) {
                            telnet.send("game.setTimeRemaining(" + totalSeconds + ")");
                        } else {
                            telnet.send("game.setTimeRemaining(None)");
                        }
                        update();
                    }
                });
        alertDialog.setButton(-2, getApplicationContext().getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        return alertDialog;
    }
    return null;
}