Example usage for android.app AlertDialog.Builder setMessage

List of usage examples for android.app AlertDialog.Builder setMessage

Introduction

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

Prototype

public void setMessage(CharSequence message) 

Source Link

Usage

From source file:de.j4velin.wifiAutoOff.Locations.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Database db = Database.getInstance(this);
    locations = db.getLocations();/* w  ww.j a va 2s  . co m*/
    db.close();

    setContentView(R.layout.locations);

    findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            if (PREMIUM_ENABLED || locations.size() < 1) {
                startActivityForResult(new Intent(Locations.this, Map.class), REQUEST_LOCATION);
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(Locations.this);
                builder.setMessage(R.string.buy_pro);
                builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, int which) {
                        try {
                            Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(),
                                    "de.j4velin.wifiautomatic.billing.pro", "inapp", getPackageName());
                            if (buyIntentBundle.getInt("RESPONSE_CODE") == 0) {
                                PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                                startIntentSenderForResult(pendingIntent.getIntentSender(), REQUEST_BUY, null,
                                        0, 0, 0);
                            }
                        } catch (Exception e) {
                            if (BuildConfig.DEBUG)
                                Logger.log(e);
                            Toast.makeText(Locations.this, e.getClass().getName() + ": " + e.getMessage(),
                                    Toast.LENGTH_LONG).show();
                            e.printStackTrace();
                        }
                        dialog.dismiss();
                    }
                });
                builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.create().show();
            }
        }
    });

    mRecyclerView = (RecyclerView) findViewById(R.id.locations);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    mAdapter = new LocationsAdapter();
    mRecyclerView.setAdapter(mAdapter);

    PREMIUM_ENABLED |= getSharedPreferences("settings", Context.MODE_PRIVATE).getBoolean("pro", false);
    if (!PREMIUM_ENABLED) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND")
                .setPackage("com.android.vending"), mServiceConn, Context.BIND_AUTO_CREATE);
    }

    findViewById(R.id.timeoutwarning).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            getSharedPreferences(getPackageName() + "_preferences", Context.MODE_MULTI_PROCESS).edit()
                    .putInt("no_network_timeout", 5).commit();
            v.setVisibility(View.GONE);
        }
    });

}

From source file:com.masteriti.manager.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *//*from w  ww.  j  ava 2 s . c o  m*/
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                // Set "connecting" status
                SharedPreferences prefs = Util.getSharedPreferences(mContext);
                prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit();
                // Get account name
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                // Register
                register((String) account.getText());
                finish();
            }
        });
    }
}

From source file:com.restswitch.controlpanel.MainActivity.java

private void alertInfo(String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Information");
    builder.setMessage(msg);
    builder.setNeutralButton("OK", null);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    builder.show();//from   w  w w  .j a v  a 2  s.co  m
}

From source file:com.ame.armymax.SearchActivity.java

@Override
public void onBackPressed() {
    super.onBackPressed();
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override//from w  w w  . j  av  a  2s.  co  m
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                Intent i = new Intent(SearchActivity.this, MainActivity.class);
                finish();
                startActivity(i);
                break;

            case DialogInterface.BUTTON_NEGATIVE:
                dialog.dismiss();
                break;
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("????")
            .setPositiveButton("", dialogClickListener)
            .setNegativeButton("", dialogClickListener).show();

}

From source file:com.hybris.mobile.app.commerce.adapter.AccountPaymentAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    View rowView;//  w w w  .  j av a  2s  .  co m

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_payment_details, parent, false);
        rowView.setTag(new PaymentViewHolder(rowView, position));
    } else {
        rowView = convertView;
    }

    PaymentViewHolder mPaymentViewHolder = (PaymentViewHolder) rowView.getTag();

    final PaymentDetails paymentDetails = getItem(position);

    if (paymentDetails != null) {

        mPaymentViewHolder.paymentCardholderName.setText(paymentDetails.getAccountHolderName());
        mPaymentViewHolder.cardDetails
                .setText(paymentDetails.getCardType().getName() + "\n" + paymentDetails.getCardNumber() + "\n"
                        + paymentDetails.getExpiryMonth() + "/" + paymentDetails.getExpiryYear());

        if (paymentDetails.getBillingAddress() != null) {

            mPaymentViewHolder.billingAddress
                    .setText(StringUtils.isNotBlank(paymentDetails.getBillingAddress().getFormattedAddress())
                            ? paymentDetails.getBillingAddress().getFormattedAddress()
                            : paymentDetails.getBillingAddress().getLine1() + " "
                                    + paymentDetails.getBillingAddress().getLine2() + ",\n "
                                    + paymentDetails.getBillingAddress().getTown() + " "
                                    + paymentDetails.getBillingAddress().getPostalCode());
        }

        mPaymentViewHolder.paymentDefaultImageView.setVisibility(View.GONE);
        mPaymentViewHolder.paymentSetDefaultButton.setVisibility(View.INVISIBLE);

        mPaymentViewHolder.paymentDefaultImageView.setVisibility(position == 0 ? View.VISIBLE : View.INVISIBLE);
        //mPaymentViewHolder.paymentSetDefaultButton.setVisibility(position == 0 ? View.INVISIBLE : View.VISIBLE);
        mPaymentViewHolder.paymentDeleteButton.setVisibility(View.VISIBLE);

        mPaymentViewHolder.paymentSetDefaultButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                setDefaultPayment(paymentDetails);
                Alert.showSuccess(getContext(),
                        getContext().getString(R.string.payment_default_updated_message));

            }
        });

        mPaymentViewHolder.paymentDetailsLayout.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mOnPaymentSelectedListener.onPaymentSelected(paymentDetails);
            }
        });
    }

    mPaymentViewHolder.paymentDeleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog dialog;
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setMessage(R.string.payment_delete_message)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                            QueryPayment queryPayment = new QueryPayment();
                            queryPayment.setPaymentDetailsId(paymentDetails.getId());

                            CommerceApplication.getContentServiceHelper()
                                    .deleteUserPaymentDetails(new ResponseReceiverEmpty() {
                                        @Override
                                        public void onResponse(Response<EmptyResponse> response) {

                                            Alert.showSuccess(getContext(), getContext()
                                                    .getString(R.string.payment_delete_success_message));

                                            if (position < mPaymentList.size()) {
                                                mPaymentList.remove(position);
                                            }
                                            mOnPaymentSelectedListener.onPaymentListRefreshed();

                                            //Default is the first but if deleted select the next one as default
                                            if (mPaymentList != null && !mPaymentList.isEmpty()
                                                    && position == 0) {
                                                setDefaultPayment(mPaymentList.get(0));
                                            }
                                        }

                                        @Override
                                        public void onError(Response<ErrorList> response) {

                                        }
                                    }, null, queryPayment, null, false, null, null);

                            dialog.dismiss();

                        }
                    }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });

            dialog = builder.create();
            dialog.show();
        }
    });

    return rowView;
}

From source file:com.phonegap.Notification.java

/**
 * Builds and shows a native Android confirm dialog with given title, message, buttons.
 * This dialog only shows up to 3 buttons.  Any labels after that will be ignored.
 * The index of the button pressed will be returned to the JavaScript callback identified by callbackId.
 * /*from www  .  j a  v a  2s.  c  o m*/
 * @param message       The message the dialog should display
 * @param title       The title of the dialog
 * @param buttonLabels    A comma separated list of button labels (Up to 3 buttons)
 * @param callbackId   The callback id
 */
public synchronized void confirm(final String message, final String title, String buttonLabels,
        final String callbackId) {

    final PhonegapActivity ctx = this.ctx;
    final Notification notification = this;
    final String[] fButtons = buttonLabels.split(",");

    Runnable runnable = new Runnable() {
        public void run() {
            AlertDialog.Builder dlg = new AlertDialog.Builder(ctx);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            // First button
            if (fButtons.length > 0) {
                dlg.setPositiveButton(fButtons[0], new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        notification.success(new PluginResult(PluginResult.Status.OK, 1), callbackId);
                    }
                });
            }

            // Second button
            if (fButtons.length > 1) {
                dlg.setNeutralButton(fButtons[1], new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        notification.success(new PluginResult(PluginResult.Status.OK, 2), callbackId);
                    }
                });
            }

            // Third button
            if (fButtons.length > 2) {
                dlg.setNegativeButton(fButtons[2], new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        notification.success(new PluginResult(PluginResult.Status.OK, 3), callbackId);
                    }
                });
            }

            dlg.create();
            dlg.show();
        };
    };
    this.ctx.runOnUiThread(runnable);
}

From source file:com.starwood.anglerslong.LicenseActivity.java

/*****************************************************************************************************
 * Handles the onClick of the button/image
 *****************************************************************************************************
 * @param v Holds the clicked view/* w w  w  .  ja v a  2s  . com*/
 *****************************************************************************************************/
private void clickedItem(View v) {
    for (int i = 0; i < imageViewIdArray.length; i++) {
        if (v.getId() == imageViewIdArray[i]) {
            currentItemID = i;
            break;
        }
    }

    //*******************************************************************************************************
    // Only goes here if they clicked the DELETE button in the actionbar menu.
    //*******************************************************************************************************
    if (isDeletable) {
        AlertDialog.Builder builder = new AlertDialog.Builder(LicenseActivity.this);
        builder.setMessage("Are you sure you want to delete this item from the list?").setTitle("Delete")
                .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        try {
                            delete(currentItemID);
                            onBackPressed();
                            Toast.makeText(getApplicationContext(), "Your item has been deleted!",
                                    Toast.LENGTH_SHORT).show();
                        } catch (IOException | JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {

                    }
                });

        AlertDialog alert = builder.create();
        alert.show();
        isDeletable = false;
    }
    //*******************************************************************************************************
    // Go here if you just want to click the item, see info that's stored, and possibly add to it.
    //*******************************************************************************************************
    else {
        isEdit = true;
        Intent intent = new Intent();
        intent.setClass(getApplicationContext(), LicenseAddActivity.class);
        intent.putExtra("title", "License");
        intent.putExtra("isPopulated", isLicensePopulated);
        intent.putExtra("isArrayEmpty", isArrayEmpty);
        intent.putExtra("isEdit", isEdit);
        intent.putExtra("currentItemID", currentItemID);
        intent.putExtra("isLicense", true);
        startActivity(intent);
    }
}

From source file:com.mendhak.gpslogger.common.PrefsIO.java

private void ReAskFileName() {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.FileExists);
    builder.setMessage(R.string.AskAnotherFile);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override/*from w  w  w. ja  va  2  s.  c o m*/
        public void onClick(DialogInterface dialog, int which) {
            AskFileName();
        }
    });
    builder.show();
}

From source file:com.capstonecontrol.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *///from   w w w. jav  a  2  s.c  o  m
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                CapstoneControlActivity.userChanged = true;
                // Set "connecting" status
                SharedPreferences prefs = Util.getSharedPreferences(mContext);
                prefs.edit().putString(Util.CONNECTION_STATUS, Util.CONNECTING).commit();
                // Get account name
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                // Register
                register((String) account.getText());
                // finish();
                // clear the module list so that a new one will get found
                CapstoneControlActivity.modules.clear();
                // instead of finish() go back to the AccountsActivity for
                // new login.
                CapstoneControlActivity.googleUserName = (String) account.getText();
                Intent myIntent = new Intent(v.getContext(), SplashActivity.class);
                startActivity(myIntent);
                myIntent = new Intent(v.getContext(), CapstoneControlActivity.class);
                startActivity(myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
            }
        });
    }
}

From source file:com.listomate.activities.AccountsActivity.java

/**
 * Sets up the 'connect' screen content.
 *///from   w  w w. j ava 2 s .c o  m
private void setConnectScreenContent() {
    List<String> accounts = getGoogleAccounts();
    if (accounts.size() == 0) {
        // Show a dialog and invoke the "Add Account" activity if requested
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(R.string.needs_account);
        builder.setPositiveButton(R.string.add_account, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
            }
        });
        builder.setNegativeButton(R.string.skip, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.setIcon(android.R.drawable.stat_sys_warning);
        builder.setTitle(R.string.attention);
        builder.show();
    } else {
        final ListView listView = (ListView) findViewById(R.id.select_account);
        listView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.account, accounts));
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setItemChecked(mAccountSelectedPosition, true);

        final Button connectButton = (Button) findViewById(R.id.connect);
        connectButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                // Register in the background and terminate the activity
                mAccountSelectedPosition = listView.getCheckedItemPosition();
                TextView account = (TextView) listView.getChildAt(mAccountSelectedPosition);
                register((String) account.getText());
                finish();
            }
        });

        final Button exitButton = (Button) findViewById(R.id.exit);
        exitButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });
    }
}