Java Code Examples for android.support.v7.app.AlertDialog.setMessage()

The following are Jave code examples for showing how to use setMessage() of the android.support.v7.app.AlertDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Overkill   File: MainActivity.java   Source Code and License Vote up 6 votes
private void checkInternetConnection() {
    ConnectivityManager  cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if ( netInfo == null || !netInfo.isConnectedOrConnecting() ) {
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle("Warning");
        alertDialog.setMessage("This app has limited functions without the internet connection.");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }
}
 
Example 2
Project: Overkill   File: MainActivity.java   Source Code and License Vote up 6 votes
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (requestCode == MYPERMISSION) {
        if (grantResults.length < 0 || grantResults[0] != PackageManager.PERMISSION_GRANTED) {
            AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
            alertDialog.setTitle("Please!!");
            alertDialog.setMessage("ALLOW map permission.");
            alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            alertDialog.show();
        }
    }
}
 
Example 3
Project: Goalie_Android   File: GoalsDetailedDialog.java   Source Code and License Vote up 6 votes
private void delete() {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setTitle(getString(R.string.are_you_sure));
    alertDialog.setMessage(getString(R.string.no_refund));
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            GoalHelper.getInstance().deleteGoal(mGuid);
            Intent returnIntent = new Intent();
            String goalCompleteResultString = String.valueOf(Goal.GoalCompleteResult.Cancelled.ordinal());
            returnIntent.putExtra("goalCompleteResultInt", goalCompleteResultString);
            getTargetFragment().onActivityResult(getTargetRequestCode(), Activity.RESULT_OK, returnIntent);
            dismiss();
        }
    });
    alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), (DialogInterface.OnClickListener) null);
    alertDialog.show();
}
 
Example 4
Project: Minitask   File: AddTodoItem.java   Source Code and License Vote up 6 votes
@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
    // if the date is in the past tell user to choose again
    if (dateTimeUtils.checkInvalidDate(year, monthOfYear, dayOfMonth)){
        AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
        alertDialog.setTitle("Date not valid!");
        alertDialog.setIcon(R.drawable.ic_warning_black_24dp);
        alertDialog.setMessage("You are selecting a time a point of time in the past!");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
        return;
    }

    // set date value to the value user selected and change the text
    date = dateTimeUtils.dateToString(year, monthOfYear, dayOfMonth);
    reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
 
Example 5
Project: Minitask   File: AddTodoItem.java   Source Code and License Vote up 6 votes
@Override
public void onTimeSet(TimePickerDialog view, int hourOfDay, int minute, int second) {
    // if date is not chosen first but time is chosen -> make today the default date.
    // also check for valid time, must be today but not the past hour or minutes.
    if (date.equals(dateTimeUtils.fillDateIfEmpty("")) && dateTimeUtils.checkInvalidTime(hourOfDay, minute)) {
        AlertDialog alertDialog = new AlertDialog.Builder(AddTodoItem.this).create();
        alertDialog.setTitle("Time not valid!");
        alertDialog.setMessage("You are selecting a point of time in the past!");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        alertDialog.show();
        return;
    }

    // set time value and update text
    time = dateTimeUtils.timeToString(hourOfDay, minute);
    reminderText.setText(getString(R.string.reminder_set_at) + " " + date + " " + time);
}
 
Example 6
Project: Roomie   File: BackpackActivity.java   Source Code and License Vote up 5 votes
private void showDialog(String message)
{
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Warning!");
    alertDialog.setMessage(message);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 7
Project: happy-news   File: PostFragment.java   Source Code and License Vote up 5 votes
/**
 * Refresh the content.
 *
 * <p>Shows an error message when the app is not connected to the internet.
 */
protected void refresh() {
    ConnectivityManager connectivityManager = (ConnectivityManager) getActivity().getSystemService(Context
        .CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();

    boolean isConnected = activeNetwork != null && activeNetwork.isConnected();

    if (!isConnected) {
        AlertDialog alert = new AlertDialog.Builder(getActivity()).create();

        alert.setTitle(getString(R.string.network_error_title));
        alert.setMessage(getString(R.string.no_internet_message));
        alert.setButton(RESULT_OK, getString(R.string.retry_button), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //Display an error if still not connected
                refresh();
            }
        });

        alert.show();
    } else {
        swipeRefresh.setRefreshing(true);
        loading = true;

        doRefresh(postManager, refreshCallback);
    }
}
 
Example 8
Project: Goalie_Android   File: NewGoalFragment.java   Source Code and License Vote up 5 votes
@Override
public void onSetGoal(boolean isSuccessful, String errMsg) {
    if (isSuccessful) {
        Toast.makeText(getActivity(), getString(R.string.ok_goal), Toast.LENGTH_SHORT).show();
        getActivity().setResult(Activity.RESULT_OK);
        getActivity().finish();
    } else {
        AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
        alertDialog.setTitle(getString(R.string.error_goal));
        alertDialog.setMessage(errMsg);
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), (DialogInterface.OnClickListener) null);
        alertDialog.show();
    }
}
 
Example 9
Project: MobileAppForPatient   File: RegisterUser.java   Source Code and License Vote up 5 votes
@Override
protected void initUI() {
    mScrollView = (ScrollView) findViewById(R.id.scroll_register_user);

    initUserName();
    initPassword();
    initGivenName();
    initEmail();
    initPhone();
    initFamilyName();
    initGenderSpinner();
    initBirthDate();
    initCity();
    initButtonSignUp();

    AlertDialog alertDialog = new AlertDialog.Builder(RegisterUser.this).create();
    alertDialog.setTitle("Message");
    final Intent changePssActivity = new Intent(this, LoginActivity.class);
    alertDialog.setMessage("Call your API for Register your User");
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    startActivity(changePssActivity);
                    finish();
                }
            });
    alertDialog.show();
}
 
Example 10
Project: S3-16-simone   File: FullscreenBaseGameActivity.java   Source Code and License Vote up 5 votes
private void showConnectionErrorDialog(){
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Connection error");
    alertDialog.setMessage("Simone was not able to reach Google Games. Enable connection to improve your experience with Simone.");
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 11
Project: TapIn   File: employeeTimetable.java   Source Code and License Vote up 4 votes
public void getCurrentEmployees()
{
    final ArrayList<String> info = new ArrayList<String>();

    BackgroundTask backgroundTask = new BackgroundTask(new BackgroundTask.AsyncResponse()
    {
        @Override
        public void processFinish(String output)
        {
            if (output.equals("null"))
            {
                spinner.setVisibility(View.INVISIBLE);

                AlertDialog alertDialog = new AlertDialog.Builder(employeeTimetable.this).create();
                alertDialog.setTitle("Sorry");
                alertDialog.setMessage("Some has gone wrong. Please Try Again Later");
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Okay",
                        new DialogInterface.OnClickListener()
                        {
                            public void onClick(DialogInterface dialog, int which)
                            {
                                Intent intent2 = new Intent(getApplicationContext(), EmployerMain.class);
                                intent2.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(intent2);
                                finish();
                            }
                        });
                alertDialog.show();
            }
            else
            {
                String[] tokens = output.split("-");

                for (String t : tokens)
                {
                    info.add(t);
                }

                for (int i = 0; i < info.size(); i++)
                {
                    String employee = info.get(i);

                    String[] splitInfo = employee.split(",");

                    Employee n = new Employee(i, splitInfo[0], splitInfo[1], splitInfo[2], splitInfo[3], splitInfo[4], splitInfo[5]);
                    currentEmployees.add(n);
                }

                spinner.setVisibility(View.INVISIBLE);
                scroll = new EmployeeScroll(getApplicationContext(), currentEmployees, 1);
                listView.setAdapter(scroll);

                scroll.day = day;
                scroll.month = month;
            }
        }
    });
    if( BackgroundTask.isNetworkAvailable(employeeTimetable.this))
    {
        backgroundTask.execute("eWorkingCheck", cid, day, month);
    }
    else
    {
        finish();
        Toast.makeText(employeeTimetable.this,"No internet connection", Toast.LENGTH_LONG ).show();
    }

}
 
Example 12
Project: CuYemek   File: MainActivity.java   Source Code and License Vote up 4 votes
@Override
public void onItem(int index) {
    if (!networkControl()){
        AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
        alertDialog.setTitle("İnternet Yok !");
        alertDialog.setMessage("Lütfen internet bağlantısını kontrol ediniz.");
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Tamam",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        alertDialog.show();
    }else{

        String[] cafeterias = getResources().getStringArray(R.array.cafeterias);

        TextView tvCafeterias = toolbar.findViewById(R.id.tvCafeterias);
        tvCafeterias.setText(cafeterias[index]);

        Eat eat = new Eat();
        if (eatList.getEats().size() != 0){
            eat = eatList.getEats().get(index);
            Bundle bundle = new Bundle();
            bundle.putSerializable("eat", eat);
            transaction = fragmentManager.beginTransaction();
            CafeteriaDetailFragment cafeteriaDetailFragment = new CafeteriaDetailFragment();
            cafeteriaDetailFragment.setArguments(bundle);
            transaction.replace(R.id.container , cafeteriaDetailFragment);
            transaction.addToBackStack(null);
            transaction.commit();
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            toolbar.setNavigationOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    fragmentManager.popBackStack();
                    reNameTitle();
                    getSupportActionBar().setDisplayHomeAsUpEnabled(false);
                }
            });
        }
    }

}
 
Example 13
Project: SimpleDialogFragments   File: CustomViewDialog.java   Source Code and License Vote up 4 votes
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog dialog = (AlertDialog) super.onCreateDialog(savedInstanceState);

    layoutInflater = dialog.getLayoutInflater();

    View content = onCreateContentView(savedInstanceState);

    // Intermediate view with custom message TextView
    View intermediate = inflate(R.layout.simpledialogfragment_custom_view);
    TextView textView = (TextView) intermediate.findViewById(R.id.customMessage);
    View topSpacer = intermediate.findViewById(R.id.textSpacerNoTitle);
    ViewGroup container = (ViewGroup) intermediate.findViewById(R.id.customView);
    container.addView(content);

    dialog.setView(intermediate);


    String msg = getArgString(MESSAGE);
    if (msg != null) {
        CharSequence message;
        if (getArguments().getBoolean(HTML)) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                message = Html.fromHtml(msg, 0);
            } else {
                //noinspection deprecation
                message = Html.fromHtml(msg);
            }
        } else {
            message = msg;
        }
        textView.setText(message);

    } else {
        textView.setVisibility(View.GONE);
    }
    dialog.setMessage(null);

    topSpacer.setVisibility(getArgString(TITLE) == null && msg != null ? View.VISIBLE : View.GONE);


    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface d) {
            positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    pressPositiveButton();
                }
            });
            onDialogShown();

        }
    });

    return dialog;
}
 
Example 14
Project: Lamp   File: TimingActivity.java   Source Code and License Vote up 4 votes
private void sendTime() {
    if (switchOpen) {

        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle(getResources().getString(R.string.remind));
        dialog.setMessage(getResources().getString(R.string.wait));
        dialog.show();

        Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int min = c.get(Calendar.MINUTE);

        String hourStr = hour + "";
        String minStr = min + "";

        if (hour < 10) {
            hourStr = "0" + hour + "";
        }

        if (min < 10) {
            minStr = "0" + min + "";
        }

        ControlLight.sendTime(CommandUtils.TIMING_CURRENT, hourStr, minStr);
        startAPM.postDelayed(new Runnable() {
            @Override
            public void run() {
                ControlLight.sendTime(CommandUtils.TIMING_ON_1, time[0], time[1]);

                startAPM.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ControlLight.sendTime(CommandUtils.TIMING_ON_2, time[2], time[3]);
                        dialog.cancel();
                        finishThis();
                    }
                }, 1000);

            }
        }, 1000);


    } else {
        ControlLight.sendOrder(CommandUtils.TIMING_OFF);

        finishThis();
    }

}
 
Example 15
Project: MobileAppForPatient   File: SettingsActivity.java   Source Code and License Vote up 4 votes
@Override
protected void initUI() {

    AlertDialog alertDialog = new AlertDialog.Builder(SettingsActivity.this).create();
    alertDialog.setTitle("Message");
    final Intent changePssActivity = new Intent(this, DashboardActivity.class);
    alertDialog.setMessage("Call your API for setting device send timeout");
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    startActivity(changePssActivity);
                    finish();
                }
            });
    alertDialog.show();

    mNewSettings = new CognitoUserSettings();
    settingsChanged = false;
   // mSmsSwitch = (Switch) findViewById(R.id.switchSettingsPhone);
    mTxtDataIntervalTitle = (TextView) findViewById(R.id.textViewDataIntervalTitle);
    mTxtDataIntervalValue = (TextView) findViewById(R.id.textViewDataIntervalValue);
    //mSettings = CognitoHelper.getUserDetails().getSettings().getSettings();

    if (mSmsSwitch != null) {
        mSmsSwitch.setClickable(true);
        mSmsSwitch.setChecked(false);
        mSmsSwitch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toggleSwitch();
                if (mSmsSwitch.isChecked()) {
                    updateSetting(Constants.phoneNumber, Constants.SMS1);
                } else {
                    updateSetting(Constants.phoneNumber, null);
                }
            }
        });
    }
    if (mSettings != null) {
        if (mSettings.containsKey(Constants.phoneNumber) && mSmsSwitch != null) {
            mSmsSwitch.setClickable(true);
            if (mSettings.get(Constants.phoneNumber).contains(Constants.SMS) || mSettings.get(Constants.phoneNumber).contains(Constants.SMS1)) {
                mSmsSwitch.setChecked(true);
                mSmsSwitch.setTextColor(Color.parseColor("#37A51C"));
            } else {
                mSmsSwitch.setChecked(false);
                mSmsSwitch.setTextColor(Color.parseColor("#E94700"));
            }
        }
    }
}