Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.njlabs.amrita.aid.aums.AumsActivity.java

@Override
public void init(Bundle savedInstanceState) {
    setupLayout(R.layout.activity_aums, Color.parseColor("#e91e63"));

    rollNoEditText = (EditText) findViewById(R.id.roll_no);
    passwordEditText = (EditText) findViewById(R.id.pwd);

    List<String> campusDataSet = new LinkedList<>(Arrays.asList("Ettimadai", "Amritapuri", "Bangalore",
            "Mysore", "AIMS", "Business schools", "ASAS Kochi"));

    spinner = (MaterialSpinner) findViewById(R.id.spinner);
    spinner.setItems(campusDataSet);//from w ww  . java  2s .c o m

    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Amrita University does not provide an API for accessing AUMS data. "
            + "So, if any changes are made to the AUMS Website, please be patient while I try to catch up.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Got it !", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    hideSoftKeyboard();
                }
            });

    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    alert.show();

    dialog = new ProgressDialog(baseContext);
    dialog.setIndeterminate(true);
    dialog.setCancelable(false);
    dialog.setInverseBackgroundForced(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setMessage("Authenticating your credentials ... ");

    aumsPreferences = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE);
    String rollNo = aumsPreferences.getString("RollNo", "");
    String encodedPassword = aumsPreferences.getString("Password", "");
    spinner.setSelectedIndex(aumsPreferences.getInt("server_ordinal", 0));

    aums = new Aums(baseContext);

    if (!rollNo.equals("")) {
        ((EditText) findViewById(R.id.roll_no)).setText(rollNo);
        aums.studentRollNo = rollNo;
        hideSoftKeyboard();
    }

    if (!encodedPassword.equals("")) {
        ((EditText) findViewById(R.id.pwd)).setText(Security.decrypt(encodedPassword, MainApplication.key));
        hideSoftKeyboard();
    }

}

From source file:com.example.ramap.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch (item.getItemId()) {
    //TODO: Open HistoryActivity.java with ListView Array of SharedPreferences values.
    case R.id.check_in_history_menu:
        SharedPreferences loadHistory = getSharedPreferences(SAVE, MODE_PRIVATE);
        currentLocation = loadHistory.getString("name", "You're not checked in!");
        //currentLocation.setText(String.valueOf(notCheckedIn));
        loadHistory.getString(SAVE, "");
        Toast.makeText(getApplicationContext(), ("Previous check in loaded successfully!\n" + currentLocation),
                Toast.LENGTH_SHORT).show();

        //Intent intent = new Intent (getApplicationContext(), HistoryActivity.class);
        //startActivity(intent); // starts
        break;/*from w w  w.ja  v  a 2 s  . c o m*/

    //TODO: This should open a SettingsActivity.java to change settings on the application.
    //case R.id.settings_menu:
    //    Toast.makeText(getBaseContext(), "Settings option doesn't work yet.", Toast.LENGTH_SHORT).show();
    //    break;

    case R.id.about_menu:
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("About RaMap");
        alertDialog.setMessage("Developed for CISC 4400 by:\n" + "Joseph LeRoy\n" + "Kevin McCarthy\n"
                + "Alexander Despotakis\n" + "Fizan Imtiaz");
        alertDialog.show();

        //Toast.makeText(getBaseContext(), "Created by: Joseph LeRoy, Kevin McCarthy, Alexander Despotakis, Fizan Imtiaz", Toast.LENGTH_SHORT).show();
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.iStudy.Study.Renren.Util.java

/**
 * ??????/* w w w . ja v a  2 s  .c o  m*/
 * 
 * @param activity ?Activity
 * @param title   ?
 * @param text   ?
 * @param listener ?
 */
public static void showOptionWindow(Activity activity, String title, String text, OnOptionListener listener) {
    AlertDialog dialog = new AlertDialog.Builder(activity).create();
    if (title != null) {
        dialog.setTitle(title);
    }

    if (text != null) {
        dialog.setMessage(text);
    }

    final OnOptionListener oListener = listener;
    dialog.setButton(AlertDialog.BUTTON_POSITIVE, activity.getString(R.string.renren_sdk_submit),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    oListener.onOK();
                }
            });
    dialog.setButton(AlertDialog.BUTTON_NEGATIVE, activity.getString(R.string.renren_sdk_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    oListener.onCancel();
                }
            });
    dialog.show();
}

From source file:com.mercandalli.android.apps.files.file.cloud.FileCloudFragment.java

@Override
public void executeFileModel(final FileModel fileModel, final View view) {
    final AlertDialog.Builder menuAlert = new AlertDialog.Builder(getActivity());
    String[] menuList = { getString(R.string.download) };
    if (!fileModel.isDirectory() && mFileManager.isMine(fileModel)) {
        if (FileTypeModelENUM.IMAGE.type.equals(fileModel.getType())) {
            menuList = new String[] { getString(R.string.download), getString(R.string.rename),
                    getString(R.string.delete), getString(R.string.cut), getString(R.string.properties),
                    (fileModel.isPublic()) ? "Become private" : "Become public", "Set as profile" };
        } else {//from w  w w  . ja  v a  2  s . c om
            menuList = new String[] { getString(R.string.download), getString(R.string.rename),
                    getString(R.string.delete), getString(R.string.cut), getString(R.string.properties),
                    (fileModel.isPublic()) ? "Become private" : "Become public" };
        }
    }
    menuAlert.setTitle(getString(R.string.action));
    menuAlert.setItems(menuList, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            switch (item) {
            case 0:
                mFileManager.download(getActivity(), fileModel, new IListener() {
                    @Override
                    public void execute() {
                        Toast.makeText(getActivity(), "Download finished.", Toast.LENGTH_SHORT).show();
                    }
                });
                break;

            case 1:
                DialogUtils.prompt(
                        getActivity(), "Rename", "Rename " + (fileModel.isDirectory() ? "directory" : "file")
                                + " " + fileModel.getName() + " ?",
                        "Ok", new DialogUtils.OnDialogUtilsStringListener() {
                            @Override
                            public void onDialogUtilsStringCalledBack(String text) {
                                mFileManager.rename(fileModel, text, new IListener() {
                                    @Override
                                    public void execute() {
                                        if (!mFilesToCut.isEmpty()) {
                                            mFilesToCut.clear();
                                            //refreshFab();
                                        }
                                    }
                                });
                            }
                        }, "Cancel", null, fileModel.getFullName());
                break;

            case 2:
                DialogUtils.alert(
                        getContext(), "Delete", "Delete " + (fileModel.isDirectory() ? "directory" : "file")
                                + " " + fileModel.getName() + " ?",
                        "Yes", new DialogUtils.OnDialogUtilsListener() {
                            @Override
                            public void onDialogUtilsCalledBack() {
                                mFileManager.delete(fileModel, new IListener() {
                                    @Override
                                    public void execute() {
                                        if (!mFilesToCut.isEmpty()) {
                                            mFilesToCut.clear();
                                            //refreshFab();
                                        }
                                    }
                                });
                            }
                        }, "No", null);
                break;

            case 3:
                FileCloudFragment.this.mFilesToCut.add(fileModel);
                Toast.makeText(getContext(), "File ready to cut.", Toast.LENGTH_SHORT).show();
                break;

            case 4:
                DialogUtils.alert(getContext(), getString(R.string.properties) + " : " + fileModel.getName(),
                        mFileManager.toSpanned(getActivity(), fileModel), "OK", null, null, null);
                break;

            case 5:
                mFileManager.setPublic(fileModel, !fileModel.isPublic(), new IListener() {
                    @Override
                    public void execute() {
                    }
                });
                break;

            // Picture set as profile
            case 6:
                List<StringPair> parameters = new ArrayList<>();
                parameters.add(new StringPair("id_file_profile_picture", "" + fileModel.getId()));
                (new TaskPost(getActivity(), Constants.URL_DOMAIN + Config.ROUTE_USER_PUT,
                        new IPostExecuteListener() {
                            @Override
                            public void onPostExecute(JSONObject json, String body) {
                                try {
                                    if (json != null && json.has("succeed") && json.getBoolean("succeed")) {
                                        Config.setUserIdFileProfilePicture(getActivity(), fileModel.getId());
                                    }
                                } catch (JSONException e) {
                                    Log.e(getClass().getName(), "Failed to convert Json", e);
                                }
                            }
                        }, parameters)).execute();
                break;
            }
        }
    });
    AlertDialog menuDrop = menuAlert.create();
    menuDrop.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);
                        }//w w w .ja v  a2 s.  c  o m
                    });
                    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.stanford.mobisocial.dungbeetle.ui.wizard.ChangePictureActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feed_home);

    checked = new boolean[filterTypes.length];

    for (int x = 0; x < filterTypes.length; x++) {
        checked[x] = true;//from   w w w .ja v  a 2s  .  c om
    }

    findViewById(R.id.btn_broadcast).setVisibility(View.GONE);
    mContactId = getIntent().getLongExtra("contact_id", -1);
    if (mContactId == -1) {
        Uri data = getIntent().getData();
        if (data != null) {
            try {
                mContactId = Long.parseLong(data.getLastPathSegment());
            } catch (NumberFormatException e) {
            }
        }
    }

    Bundle args = new Bundle();
    args.putLong("contact_id", mContactId);
    Fragment profileFragment = new ViewProfileFragment();
    profileFragment.setArguments(args);

    doTitleBar(this, "My Profile");
    mLabels.add("View");
    mLabels.add("Edit");
    mFragments.add(profileFragment);
    mFragments.add(new EditProfileFragment());

    Uri privateUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/feeds/private");
    mLabels.add("Notes");
    Fragment feedView = new FeedViewFragment();
    args = new Bundle(args);
    args.putParcelable(FeedViewFragment.ARG_FEED_URI, privateUri);
    feedView.setArguments(args);
    //mFragments.add(feedView);

    PagerAdapter adapter = new ViewFragmentAdapter(getSupportFragmentManager(), mFragments);
    mViewPager = (ViewPager) findViewById(R.id.feed_pager);
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(this);

    ViewGroup group = (ViewGroup) findViewById(R.id.tab_frame);
    int i = 0;
    for (String s : mLabels) {
        Button button = new Button(this);
        button.setText(s);
        button.setTextSize(18f);

        button.setLayoutParams(CommonLayouts.FULL_HEIGHT);
        button.setTag(i++);
        button.setOnClickListener(mViewSelected);

        group.addView(button);
        mButtons.add(button);
    }

    // Listen for future changes
    Uri feedUri;
    if (mContactId == Contact.MY_ID) {
        feedUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/feeds/me");
    } else {
        feedUri = Uri.parse(DungBeetleContentProvider.CONTENT_URI + "/contacts");
    }
    mProfileContentObserver = new ProfileContentObserver(mHandler);
    getContentResolver().registerContentObserver(feedUri, true, mProfileContentObserver);

    onPageSelected(0);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Click on the avatar to take a profile picture of yourself.").setCancelable(false)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

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

private void MessageDialog(String msg) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(msg).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();//from  w  w w .j  a v  a 2s.co m
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java

private void showConnectToAmritaAlert() {
    AlertDialog.Builder builder = new AlertDialog.Builder(baseContext);
    builder.setMessage("Connect to the Amrita WiFi if possible, for a reliable connection to the GPMS Server.")
            .setCancelable(true).setIcon(R.drawable.ic_action_info_small)
            .setPositiveButton("Ok. I'll connect.", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
                    finish();//from  w w w .  java 2s. c o  m
                }
            }).setNegativeButton("No. I won't.", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                    initialiseGpms();
                    hideSoftKeyboard();
                }
            });

    AlertDialog alert = builder.create();
    alert.requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (!Identifier.isConnectedToAmrita(baseContext)) {
        alert.show();
    } else {
        initialiseGpms();
    }
}

From source file:org.openhab.habdroid.ui.OpenHABWidgetListFragment.java

private void showAlertDialog(String alertMessage) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage(alertMessage).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
        }//  ww  w . jav a  2 s . co  m
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.samknows.measurement.activity.SamKnowsTestViewerActivity.java

private void SingleChoice() {
    Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Choose Test?");
    // dropdown setup

    for (int i = 0; i < testList.size(); i++) {
        TestDescription td = testList.get(i);
        array_spinner[i] = td.displayName;
        array_spinner_int[i] = td.testId;
    }/*from   w ww  .  j a v a 2 s.com*/
    array_spinner[testList.size()] = "All";
    array_spinner_int[testList.size()] = -1;

    builder.setItems(array_spinner, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Log.e("", "Launch Id=" + array_spinner_int[which]);
            dialog.dismiss();
            launchTest(array_spinner_int[which]);
        }
    });
    builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            SamKnowsTestViewerActivity.this.finish();
            overridePendingTransition(0, 0);
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}