Example usage for android.app AlertDialog setMessage

List of usage examples for android.app AlertDialog setMessage

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:org.restcomm.android.olympus.MainFragment.java

private void showOkAlert(final String title, final String detail) {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity(), R.style.SimpleAlertStyle).create();
    alertDialog.setTitle(title);/*from w  w  w. j  av  a  2  s .  c o  m*/
    alertDialog.setMessage(detail);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    alertDialog.show();
}

From source file:org.wahtod.wififixer.ui.MainActivity.java

private void phoneTutNag() {
    AlertDialog dialog = new AlertDialog.Builder(this).create();
    dialog.setTitle(getString(R.string.phone_ui_tutorial));
    dialog.setMessage(getString(R.string.phone_tutorial_q));
    dialog.setIcon(R.drawable.icon);// w  w  w .ja  va 2s.  co  m
    dialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    runTutorial();
                }
            });

    dialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.later_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    PrefUtil.writeBoolean(self.get(), PrefConstants.TUTORIAL, true);
                }
            });
    dialog.show();
}

From source file:com.bangalore.barcamp.activity.WebViewActivity.java

protected Dialog onCreateDialog(int id) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    switch (id) {
    case SHOW_ERROR_DIALOG:
        alertDialog.setCancelable(false);
        alertDialog.setTitle(getString(R.string.error_title));
        alertDialog.setMessage(getString(R.string.connection_error_and_try_again));
        alertDialog.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

            @Override/*from www .  j a  v a2  s.  c om*/
            public void onClick(DialogInterface dialog, int which) {
                dismissDialog(SHOW_ERROR_DIALOG);
                WebViewActivity.this.finish();
            }
        });
        break;
    }
    return alertDialog;
}

From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java

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

    // Create the adapter that will return a fragment for each of the three primary sections of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//  ww  w.  j  a  va2 s  . c o  m
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE);
    ;
    SharedPreferences.Editor editor = settings.edit();

    // load the default parameters into SharedPreferences for the first time launch 
    int ct = settings.getInt("count", 0);
    if (ct == 0) {
        editor.putString("start", "9");
        editor.putString("end", "21");
        editor.putString("interval", "15");
        editor.putString("duration", "5");
        editor.putString("location", "On");
        editor.putString("upload", "On");
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        editor.putString("IMEI", tm.getDeviceId());
        editor.putString("brand", Build.BRAND);
        editor.putString("model", Build.MODEL);
        String phone_type = Build.BRAND + "_" + Build.MODEL;

        // motoX
        if (phone_type.equals("motorola_XT1058")) {
            editor.putString("mfcc_dist_same_semi", "13");
            editor.putString("mfcc_dist_diff_semi", "18");
            editor.putString("mfcc_dist_same_un", "13");
            editor.putString("mfcc_dist_diff_un", "18");
        }
        // nexus 4
        else if (phone_type.equals("google_Nexus 4")) {
            editor.putString("mfcc_dist_same_semi", "17");
            editor.putString("mfcc_dist_diff_semi", "22");
            editor.putString("mfcc_dist_same_un", "17");
            editor.putString("mfcc_dist_diff_un", "22");
        }
        // s2
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) {
            editor.putString("mfcc_dist_same_semi", "18");
            editor.putString("mfcc_dist_diff_semi", "25");
            editor.putString("mfcc_dist_same_un", "18");
            editor.putString("mfcc_dist_diff_un", "25");
        }
        // s3 
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) {
            editor.putString("mfcc_dist_same_semi", "16");
            editor.putString("mfcc_dist_diff_semi", "21");
            editor.putString("mfcc_dist_same_un", "16");
            editor.putString("mfcc_dist_diff_un", "21");
        }
        // s4
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) {
            editor.putString("mfcc_dist_same_semi", "14");
            editor.putString("mfcc_dist_diff_semi", "24");
            editor.putString("mfcc_dist_same_un", "14");
            editor.putString("mfcc_dist_diff_un", "24");
        }
        // other devices
        else {
            editor.putString("mfcc_dist_same_semi", "15.6");
            editor.putString("mfcc_dist_diff_semi", "21.6");
            editor.putString("mfcc_dist_same_un", "15.6");
            editor.putString("mfcc_dist_diff_un", "21.6");
            Toast.makeText(this, "Your device is not recognized and the result might not be accurate...",
                    Toast.LENGTH_SHORT).show();
        }
        Log.i("Crowd++", "First time launched");

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("Welcome to Crowd++");
        dialog.setMessage(Constants.hello_msg);
        dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dialog.show();
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20);
    }

    editor.putInt("count", ++ct);
    editor.commit();
    Log.i("Launched Count", Integer.toString(ct));
    mConst = new Constants(this);
    if (!Constants.calibration())
        Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show();
}

From source file:org.wahtod.wififixer.ui.MainActivity.java

public void showServiceAlert() {
    final Context c;
    c = this;//  w  w  w  . java  2  s.c  o m
    AlertDialog alert = new AlertDialog.Builder(c).create();
    alert.setTitle(getString(R.string.note));
    alert.setIcon(R.drawable.icon);
    alert.setMessage(getString(R.string.servicealert_message));
    alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    PrefUtil.writeBoolean(c, PrefConstants.SERVICEWARNED, true);
                }
            });
    alert.show();
}

From source file:dev.ronlemire.contactclientcloud.MainActivity.java

@SuppressWarnings("deprecation")
@Override/*from ww  w . j a v a2  s  .com*/
public void onBackPressed() {
    //super.onBackPressed();
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Exiting Application");
    alertDialog.setMessage("Are you sure?");
    alertDialog.setIcon(android.R.attr.alertDialogIcon);
    alertDialog.setButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            finish();
        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            return;
        }
    });
    alertDialog.show();

    //      new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK)
    //            .setIconAttribute(android.R.attr.alertDialogIcon)
    //            .setTitle(R.string.exitingApplication)
    //            .setMessage(R.string.shortMessage)
    //            .setPositiveButton(R.string.alert_dialog_ok,
    //                  new DialogInterface.OnClickListener() {
    //                     public void onClick(DialogInterface dialog,
    //                           int whichButton) {
    //                        finish();
    //                     }
    //                  })
    //            .setNegativeButton(R.string.alert_dialog_cancel,
    //                  new DialogInterface.OnClickListener() {
    //                     public void onClick(DialogInterface dialog,
    //                           int whichButton) {
    //                        return;
    //                     }
    //                  }).create().show();
}

From source file:net.networksaremadeofstring.cyllell.ViewCookbooks_Fragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    settings = this.getActivity().getSharedPreferences("Cyllell", 0);
    try {//from  www .  ja va2s.  co  m
        Cut = new Cuts(getActivity());
    } catch (Exception e) {
        e.printStackTrace();
    }

    dialog = new ProgressDialog(getActivity());
    dialog.setTitle("Contacting Chef");

    dialog.setMessage("Please wait: Prepping Authentication protocols");
    dialog.setIndeterminate(true);
    if (listOfCookbooks.size() < 1) {
        dialog.show();
    }

    updateListNotify = new Handler() {
        public void handleMessage(Message msg) {
            int tag = msg.getData().getInt("tag", 999999);

            if (msg.what == 0) {
                if (tag != 999999) {
                    listOfCookbooks.get(tag).SetSpinnerVisible();
                }
            } else if (msg.what == 1) {
                //Get rid of the lock
                CutInProgress = false;

                //the notifyDataSetChanged() will handle the rest
            } else if (msg.what == 99) {
                if (tag != 999999) {
                    Toast.makeText(ViewCookbooks_Fragment.this.getActivity(),
                            "An error occured during that operation.", Toast.LENGTH_LONG).show();
                    listOfCookbooks.get(tag).SetErrorState();
                }
            }
            CookbookAdapter.notifyDataSetChanged();
        }
    };

    handler = new Handler() {
        public void handleMessage(Message msg) {
            //Once we've checked the data is good to use start processing it
            if (msg.what == 0) {
                OnClickListener listener = new OnClickListener() {
                    public void onClick(View v) {
                        GetMoreDetails((Integer) v.getTag());
                    }
                };

                OnLongClickListener listenerLong = new OnLongClickListener() {
                    public boolean onLongClick(View v) {
                        //selectForCAB((Integer)v.getTag());
                        Toast.makeText(getActivity(), "This version doesn't support Cookbook editing yet",
                                Toast.LENGTH_SHORT).show();
                        return true;
                    }
                };

                CookbookAdapter = new CookbookListAdaptor(getActivity(), listOfCookbooks, listener,
                        listenerLong);
                try {
                    list = (ListView) getView().findViewById(R.id.cookbooksListView);
                } catch (Exception e) {
                    e.printStackTrace();
                }

                if (list != null) {
                    if (CookbookAdapter != null) {
                        list.setAdapter(CookbookAdapter);
                    } else {
                        //Log.e("CookbookAdapter","CookbookAdapter is null");
                    }
                } else {
                    //Log.e("List","List is null");
                }

                dialog.dismiss();
            } else if (msg.what == 200) {
                dialog.setMessage("Sending request to Chef...");
            } else if (msg.what == 201) {
                dialog.setMessage("Parsing JSON.....");
            } else if (msg.what == 202) {
                dialog.setMessage("Populating UI!");
            } else {
                //Close the Progress dialog
                dialog.dismiss();

                //Alert the user that something went terribly wrong
                AlertDialog alertDialog = new AlertDialog.Builder(context).create();
                alertDialog.setTitle("API Error");
                alertDialog.setMessage("There was an error communicating with the API:\n"
                        + msg.getData().getString("exception"));
                alertDialog.setButton2("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        //getActivity().finish();
                    }
                });
                alertDialog.setIcon(R.drawable.icon);
                alertDialog.show();
            }
        }
    };

    Thread dataPreload = new Thread() {
        public void run() {
            if (listOfCookbooks.size() > 0) {
                handler.sendEmptyMessage(0);
            } else {
                try {
                    handler.sendEmptyMessage(200);
                    Cookbooks = Cut.GetCookbooks();
                    handler.sendEmptyMessage(201);
                    JSONArray Keys = Cookbooks.names();
                    String URI = "";
                    String Version = "0.0.0";
                    JSONObject cookbook;
                    for (int i = 0; i < Cookbooks.length(); i++) {
                        cookbook = new JSONObject(Cookbooks.getString(Keys.get(i).toString()));
                        //URI = Cookbooks.getString(Keys.get(i).toString()).replaceFirst("^(https://|http://).*/cookbooks/", "");
                        //Version = Cookbooks.getString(Keys.get(i).toString())
                        //Log.i("Cookbook Name", Keys.get(i).toString());
                        URI = cookbook.getString("url").replaceFirst("^(https://|http://).*/cookbooks/", "");
                        //Log.i("Cookbook URL", URI);

                        JSONArray versions = cookbook.getJSONArray("versions");

                        Version = versions.getJSONObject(versions.length() - 1).getString("version");
                        //Log.i("Cookbook version", Version);

                        listOfCookbooks.add(new Cookbook(Keys.get(i).toString(), URI, Version));
                    }

                    handler.sendEmptyMessage(202);
                    handler.sendEmptyMessage(0);
                } catch (Exception e) {
                    BugSenseHandler.log("ViewCookbooksFragment", e);
                    e.printStackTrace();
                    Message msg = new Message();
                    Bundle data = new Bundle();
                    data.putString("exception", e.getMessage());
                    msg.setData(data);
                    msg.what = 1;
                    handler.sendMessage(msg);
                }
            }
            return;
        }
    };

    dataPreload.start();
    return inflater.inflate(R.layout.cookbooks_landing, container, false);
}

From source file:com.technologx.firebirddesigns.MainInterface.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bottom_interface);

    View main = findViewById(R.id.main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (main != null) {
            main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }//from  ww  w .  j a v  a  2 s.c  o m
    }

    AppCompatActivity activity = this;
    activity.setSupportActionBar(toolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    activity.getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_toolbar);
    activity.getSupportActionBar().setTitle("Fire Bird Designs");
    activity.getSupportActionBar().setSubtitle("News, Content and More");

    UpdateChecker checker = new UpdateChecker(this);
    UpdateChecker.setStore(Store.GOOGLE_PLAY);
    UpdateChecker.setNoticeIcon(R.mipmap.ic_launcher);
    UpdateChecker.start();

    result = new DrawerBuilder(this).withToolbar(toolbar).withDisplayBelowStatusBar(false)
            .withTranslucentStatusBar(false).withActionBarDrawerToggleAnimated(true)
            .withDrawerLayout(R.layout.material_drawer_fits_not).withHeader(R.layout.settings_header)
            .addDrawerItems(new SectionDrawerItem().withName("Application"),
                    new PrimaryDrawerItem().withName("Notifications").withIdentifier(1),
                    new PrimaryDrawerItem().withName("Homepage").withIdentifier(2),
                    new ExpandableDrawerItem().withName("More").withSubItems(
                            new PrimaryDrawerItem().withName("Settings").withIdentifier(3),
                            new PrimaryDrawerItem().withName("License").withIdentifier(4),
                            new PrimaryDrawerItem().withName("Contact").withIdentifier(5)))
            .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
                @Override
                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                    long id = drawerItem.getIdentifier();
                    if (id == 1) {
                        Intent intent = new Intent(MainInterface.this, NewsfeedActivity.class);
                        startActivity(intent);
                    } else if (id == 2) {
                        Intent intent = new Intent(MainInterface.this, WebViewActivity.class);
                        startActivity(intent);
                    } else if (id == 3) {
                        Intent intent = new Intent(MainInterface.this, SettingsActivity.class);
                        startActivity(intent);
                    } else if (id == 4) {
                        new LicensesDialog.Builder(MainInterface.this).setNotices(R.raw.licenses).build()
                                .show();

                    } else if (id == 5) {
                        AlertDialog alertDialog = new AlertDialog.Builder(MainInterface.this).create();
                        alertDialog.setTitle(getResources().getString(R.string.feedback_title));
                        alertDialog.setMessage(getResources().getString(R.string.feedback_summary));
                        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                                getResources().getString(R.string.email),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        sendEmail();
                                    }
                                });
                        alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
                                getResources().getString(R.string.hangout),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        startHangout();
                                    }
                                });
                        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                                getResources().getString(android.R.string.cancel),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                });
                        alertDialog.show();
                    }

                    return false;
                }
            }).withSavedInstance(savedInstanceState).build();

    // Setup the viewPager
    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pagerAdapter);
    viewPager.setCurrentItem(1);
    viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
        @Override
        public void transformPage(View page, float position) {
            final float normalizedposition = Math.abs(Math.abs(position) - 1);
            page.setAlpha(normalizedposition);
        }
    });

    mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
    if (mTabLayout != null) {
        mTabLayout.setupWithViewPager(viewPager);

        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
            TabLayout.Tab tab = mTabLayout.getTabAt(i);
            if (tab != null)
                tab.setCustomView(pagerAdapter.getTabView(i));
        }

        mTabLayout.getTabAt(0).getCustomView().setSelected(true);
    }
}

From source file:com.todoroo.astrid.adapter.UpdateAdapter.java

public static void setupImagePopupForCommentView(View view, AsyncImageView commentPictureView,
        final String pictureThumb, final String pictureFull, final Bitmap updateBitmap, final String message,
        final Fragment fragment, ImageCache imageCache) {
    if ((!TextUtils.isEmpty(pictureThumb) && !"null".equals(pictureThumb)) || updateBitmap != null) { //$NON-NLS-1$
        commentPictureView.setVisibility(View.VISIBLE);
        if (updateBitmap != null)
            commentPictureView.setImageBitmap(updateBitmap);
        else// ww w.  j a  va  2s .  c o m
            commentPictureView.setUrl(pictureThumb);

        if (pictureThumb != null && imageCache.contains(pictureThumb) && updateBitmap == null) {
            try {
                commentPictureView.setDefaultImageBitmap(imageCache.get(pictureThumb));
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else if (updateBitmap == null) {
            commentPictureView.setUrl(pictureThumb);
        }

        view.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog image = new AlertDialog.Builder(fragment.getActivity()).create();
                AsyncImageView imageView = new AsyncImageView(fragment.getActivity());
                imageView
                        .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                imageView.setDefaultImageResource(android.R.drawable.ic_menu_gallery);
                if (updateBitmap != null)
                    imageView.setImageBitmap(updateBitmap);
                else
                    imageView.setUrl(pictureFull);
                image.setView(imageView);

                image.setMessage(message);
                image.setButton(fragment.getString(R.string.DLG_close), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
                image.show();
            }
        });
    } else {
        commentPictureView.setVisibility(View.GONE);
    }
}

From source file:org.epstudios.epcoding.ProcedureDetailFragment.java

public void saveCoding() {
    // don't bother if no secondary codes to save
    if (secondaryCheckBoxMap.isEmpty()) {
        Toast toast = Toast.makeText(context, getString(R.string.no_secondary_codes_error_message),
                Toast.LENGTH_SHORT);/*from  www .java  2  s.  co  m*/
        toast.show();
        return;
    }
    AlertDialog dialog = new AlertDialog.Builder(context).create();
    String message = "Save these selections as a default?";
    dialog.setMessage(message);
    dialog.setTitle("Save Defaults");
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            save();
        }
    });
    dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    dialog.show();
}