use of android.content.DialogInterface in project android-app-common-tasks by multidots.
the class Common method showNETWORDDisabledAlert.
public static void showNETWORDDisabledAlert(final Context ctx) {
AlertDialog alert;
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
alertDialogBuilder.setMessage("Let the app use data connectivity.").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
ctx.startActivity(callGPSSettingIntent);
}
});
alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
alert = alertDialogBuilder.create();
alert.show();
}
use of android.content.DialogInterface in project android-app-common-tasks by multidots.
the class Common method showGPSDisabledAlert.
public static void showGPSDisabledAlert(@SuppressWarnings("SameParameterValue") String msg, final Context ctx) {
AlertDialog alert;
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
alertDialogBuilder.setMessage(msg).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
ctx.startActivity(callGPSSettingIntent);
}
});
alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
alert = alertDialogBuilder.create();
alert.show();
}
use of android.content.DialogInterface in project android-app-common-tasks by multidots.
the class Common method showAlertDialog.
/**
* Function to display simple Alert Dialog or Toast
*
* @param context - application context
* @param title - alert dialog title
* @param message - alert message
* @param toast - show as toast or dialog
*/
public static void showAlertDialog(Context context, String title, String message, boolean toast) {
if (toast) {
Toast.makeText(context, message, Toast.LENGTH_LONG).show();
} else {
if (!((Activity) context).isFinishing()) {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// Setting Dialog Title
alertDialog.setTitle(title);
// Setting Dialog Message
alertDialog.setMessage(message);
// Setting OK Button
alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
// Showing Alert Message
alertDialog.show();
}
}
}
use of android.content.DialogInterface in project android-app-common-tasks by multidots.
the class SocialAuthDialog method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handler = new Handler();
Util.getDisplayDpi(getContext());
mSpinner = new ProgressDialog(getContext());
mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
mSpinner.setMessage("Loading...");
mSpinner.setCancelable(true);
mContent = new LinearLayout(getContext());
mContent.setOrientation(LinearLayout.VERTICAL);
setUpTitle();
setUpWebView();
Display display = getWindow().getWindowManager().getDefaultDisplay();
final float scale = getContext().getResources().getDisplayMetrics().density;
int orientation = getContext().getResources().getConfiguration().orientation;
float[] dimensions = (orientation == Configuration.ORIENTATION_LANDSCAPE) ? DIMENSIONS_DIFF_LANDSCAPE : DIMENSIONS_DIFF_PORTRAIT;
addContentView(mContent, new LinearLayout.LayoutParams(display.getWidth() - ((int) (dimensions[0] * scale + 0.5f)), display.getHeight() - ((int) (dimensions[1] * scale + 0.5f))));
mSpinner.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
mWebView.stopLoading();
mListener.onBack();
SocialAuthDialog.this.dismiss();
}
});
this.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
mWebView.stopLoading();
dismiss();
mListener.onBack();
return true;
}
return false;
}
});
}
use of android.content.DialogInterface in project android-app-common-tasks by multidots.
the class Common method showNETWORDDisabledAlertToUser.
private void showNETWORDDisabledAlertToUser(final Context ctx) {
AlertDialog alert;
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctx);
alertDialogBuilder.setMessage("Let the app use data connectivity.").setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
ctx.startActivity(callGPSSettingIntent);
}
});
alertDialogBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
alert = alertDialogBuilder.create();
alert.show();
}
Aggregations