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:com.plusot.senselib.SenseMain.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override//from   w  w w. j a v a  2 s .c  o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    shouldFinish = 0;
    if (Build.VERSION.SDK_INT >= 11)
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); //.FEATURE_ACTION_BAR_OVERLAY);
    Log.d(Globals.TAG,
            CLASSTAG + ".onCreate:\n" + "   ******************************************************\n"
                    + "   *                                                    *\n"
                    + "   *                                                    *\n"
                    + "   *                  SenseMain Started                 *\n"
                    + "   *                                                    *\n"
                    + "   *                                                    *\n"
                    + "   ******************************************************");

    if (Build.VERSION.SDK_INT < 14 || ViewConfiguration.get(this).hasPermanentMenuKey())
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);
    ActivityUtil.lockScreenOrientation(this);

    app = (SenseApp) getApplication();
    app.activityCreated(SenseMain.this);
    init(getIntent(), true);

    watchId = Watchdog.addProcessS(CLASSTAG);

    String state = android.os.Environment.getExternalStorageState();
    if (!state.equals(android.os.Environment.MEDIA_MOUNTED)) {
        AlertDialog alertDialog = new AlertDialog.Builder(SenseMain.this).create();
        alertDialog.setTitle(R.string.no_sd_title);
        alertDialog.setMessage(SenseMain.this.getString(R.string.no_sd_message));
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                SenseMain.this.getString(R.string.button_confirm), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        return;
                    }
                });
        alertDialog.show();
    }
    if (SenseGlobals.screenLock)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //ActivityUtil.lockScreenOrientation(SenseMain.this);
    updateSettings();
    PreferenceHelper.getPrefs().registerOnSharedPreferenceChangeListener(this);
    LLog.i(Globals.TAG, CLASSTAG + ".onCreate. Wakelock acquired");

    Device.setListener(SenseMain.this);
    HttpSender.checkSession();
    if (System.currentTimeMillis() - Value.getSessionTime() > 3600000L * 12
            && SenseGlobals.stopState.equals(SenseGlobals.StopState.PAUZE)) {
        closeValues(SenseGlobals.ActivityMode.STOP, false);
        PreferenceKey.setStopState(SenseGlobals.StopState.STOP);
    }
    if (SenseApp.firstActivity && SenseGlobals.loadSplash) {
        //creating = true;
        showSplashScreen(true);
        if (SenseGlobals.isBikeApp) {
            View view = this.findViewById(R.id.main_layout);
            if (view != null)
                view.setVisibility(View.INVISIBLE);
        }
    }
    SenseApp.firstActivity = false;
    Watchdog.getInstance().add(this, 1000);
    Watchdog.getInstance().add(this);

    //for (PreferenceKey prefKey : PreferenceKey.values()) updateSetting(prefs, prefKey);
    //if (PreferenceKey.HASMAP.isTrue()) addMap();
    try {
        PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
        setTitle(Globals.appName + " " + info.versionName);
    } catch (NameNotFoundException ignored) {

    }
    File file = new File(SenseGlobals.getGpxPath());
    if (!file.isDirectory() && !file.mkdirs()) {
        Log.w(Globals.TAG, CLASSTAG + " Could not create: " + SenseGlobals.getGpxPath());
    }
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Show an alert//  w w  w. j a v  a 2  s.  com
 * @param context used to display the alert window
 * @param title the title of the alert window. Use {@code null} to show no title
 * @param text the alert message
 * @see #alert(Context, String)
 */
public static void alert(Context context, String title, String text) {
    AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setTitle(title);
    alert.setMessage(text);
    alert.setButton("OK", new OnClickListener() {

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

    });
    alert.show();
}

From source file:self.philbrown.droidQuery.$.java

/**
 * Uses the current context to show an alert dialog.
 * @param title the alert title/* w  ww.java  2 s .co  m*/
 * @param text the alert message.
 * @see #alert(String)
 */
public void alert(String title, String text) {
    AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setTitle(title);
    alert.setMessage(text);
    alert.setButton("OK", new OnClickListener() {

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

    });
    alert.show();
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

/**
 * ADW: Put the launcher in desktop edit mode We could be able to add,
 * remove and reorder screens/*from   w w  w.j a va2  s .c  o  m*/
 */
private void startDesktopEdit() {
    if (!mIsEditMode) {
        mIsEditMode = true;
        final PersonaWorkspace personaWorkspace = mWorkspace;
        if (personaWorkspace == null)
            return;
        personaWorkspace.enableChildrenCache(0, personaWorkspace.getChildCount());
        hideDesktop(true);
        personaWorkspace.lock();
        // Load a gallery view
        final PersonaScreensAdapter screens = new PersonaScreensAdapter(this,
                personaWorkspace.getChildAt(0).getWidth(), personaWorkspace.getChildAt(0).getHeight());
        for (int i = 0; i < personaWorkspace.getChildCount(); i++) {
            screens.addScreen((PersonaCellLayout) personaWorkspace.getChildAt(i));
        }
        mScreensEditor = mInflater.inflate(R.layout.pr_screens_editor, null);
        final Gallery gal = (Gallery) mScreensEditor.findViewById(R.id.gallery_screens);
        gal.setCallbackDuringFling(false);
        gal.setClickable(false);
        gal.setAdapter(screens);
        // Setup delete button event
        View deleteButton = mScreensEditor.findViewById(R.id.delete_screen);
        deleteButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                final int screenToDelete = gal.getSelectedItemPosition();
                if (personaWorkspace.getChildCount() > 1) {
                    AlertDialog alertDialog = new AlertDialog.Builder(PersonaLauncher.this).create();
                    alertDialog.setTitle(getResources().getString(R.string.title_dialog_xml));
                    alertDialog.setMessage(getResources().getString(R.string.message_delete_desktop_screen));
                    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE,
                            getResources().getString(android.R.string.ok),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    personaWorkspace.removeScreen(screenToDelete);
                                    screens.removeScreen(screenToDelete);
                                }
                            });
                    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                            getResources().getString(android.R.string.cancel),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            });
                    alertDialog.show();
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this,
                            R.string.message_cannot_delete_desktop_screen, Toast.LENGTH_LONG);
                    t.show();
                }

            }
        });
        // Setup add buttons events
        View addLeftButton = mScreensEditor.findViewById(R.id.add_left);
        addLeftButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                if (screens.getCount() < MAX_SCREENS) {
                    final int screenToAddLeft = gal.getSelectedItemPosition();
                    PersonaCellLayout newScreen = personaWorkspace.addScreen(screenToAddLeft);
                    screens.addScreen(newScreen, screenToAddLeft);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_add_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        View addRightButton = mScreensEditor.findViewById(R.id.add_right);
        addRightButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                if (screens.getCount() < MAX_SCREENS) {
                    final int screenToAddRight = gal.getSelectedItemPosition();
                    PersonaCellLayout newScreen = personaWorkspace.addScreen(screenToAddRight + 1);
                    screens.addScreen(newScreen, screenToAddRight + 1);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_add_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });

        final View swapLeftButton = mScreensEditor.findViewById(R.id.swap_left);
        swapLeftButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                int currentScreen = gal.getSelectedItemPosition();
                if (currentScreen > 0) {
                    personaWorkspace.swapScreens(currentScreen - 1, currentScreen);
                    screens.swapScreens(currentScreen - 1, currentScreen);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_swap_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        final View swapRightButton = mScreensEditor.findViewById(R.id.swap_right);
        swapRightButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                int currentScreen = gal.getSelectedItemPosition();
                if (currentScreen < gal.getCount() - 1) {
                    personaWorkspace.swapScreens(currentScreen, currentScreen + 1);
                    screens.swapScreens(currentScreen, currentScreen + 1);
                } else {
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.message_cannot_swap_desktop_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        final View setDefaultButton = mScreensEditor.findViewById(R.id.set_default);
        setDefaultButton.setOnClickListener(new android.view.View.OnClickListener() {
            public void onClick(View v) {
                int currentScreen = gal.getSelectedItemPosition();
                if (currentScreen < mWorkspace.getChildCount()) {
                    mWorkspace.setDefaultScreen(currentScreen);
                    PersonaAlmostNexusSettingsHelper.setDefaultScreen(PersonaLauncher.this, currentScreen);
                    Toast t = Toast.makeText(PersonaLauncher.this, R.string.pref_title_default_screen,
                            Toast.LENGTH_LONG);
                    t.show();
                }
            }
        });
        gal.setOnItemSelectedListener(new OnItemSelectedListener() {
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (position <= 0) {
                    swapLeftButton.setVisibility(View.GONE);
                } else {
                    swapLeftButton.setVisibility(View.VISIBLE);
                }
                if (position < parent.getCount() - 1) {
                    swapRightButton.setVisibility(View.VISIBLE);
                } else {
                    swapRightButton.setVisibility(View.GONE);
                }
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }

        });
        mDragLayer.addView(mScreensEditor);
    }
}

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

@Override
public void onPrepareDialog(int id, Dialog d) {
    AlertDialog alert = (AlertDialog) d;
    switch (id) {
    case DIALOG_REMOVE_ACCOUNT: {
        alert.setMessage(getString(R.string.account_delete_dlg_instructions_fmt,
                mSelectedContextAccount.getDescription()));
        break;//  w ww  .j a v  a 2  s .  c o  m
    }
    case DIALOG_CLEAR_ACCOUNT: {
        alert.setMessage(getString(R.string.account_clear_dlg_instructions_fmt,
                mSelectedContextAccount.getDescription()));
        break;
    }
    case DIALOG_RECREATE_ACCOUNT: {
        alert.setMessage(getString(R.string.account_recreate_dlg_instructions_fmt,
                mSelectedContextAccount.getDescription()));
        break;
    }
    }

    super.onPrepareDialog(id, d);
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

@SuppressWarnings("unused")
void addSearch() {
    final PersonaWidget info = PersonaWidget.makeSearch();
    final PersonaCellLayout.CellInfo cellInfo = mAddItemCellInfo;

    final int[] xy = mCellCoordinates;
    final int spanX = info.spanX;
    final int spanY = info.spanY;

    AlertDialog.Builder builder;// w w w . j  a v  a2s . co m
    AlertDialog alertDialog;

    final View dlg_layout = View.inflate(PersonaLauncher.this, R.layout.pr_widget_span_setup, null);
    final PersonaNumberPicker ncols = (PersonaNumberPicker) dlg_layout.findViewById(R.id.widget_columns_span);
    ncols.setRange(1, mWorkspace.currentDesktopColumns());
    ncols.setCurrent(spanX);
    final PersonaNumberPicker nrows = (PersonaNumberPicker) dlg_layout.findViewById(R.id.widget_rows_span);
    nrows.setRange(1, mWorkspace.currentDesktopRows());
    nrows.setCurrent(spanY);
    builder = new AlertDialog.Builder(PersonaLauncher.this);
    builder.setView(dlg_layout);
    alertDialog = builder.create();
    alertDialog.setTitle(getResources().getString(R.string.widget_config_dialog_title));
    alertDialog.setMessage(getResources().getString(R.string.widget_config_dialog_summary));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    int spanX = ncols.getCurrent();
                    int spanY = nrows.getCurrent();
                    // realAddSearch(info,cellInfo,xy,spanX,spanY);
                }
            });
    alertDialog.show();
}