List of usage examples for android.app AlertDialog.Builder setOnCancelListener
public void setOnCancelListener(@Nullable OnCancelListener listener)
From source file:com.mono.applink.Foursquare.java
/** Called when the activity is first created. */ @Override/*from w ww. ja v a 2 s. c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String url = getIntent().getData().toString(); if (url.contains("user"))//user with id { new FoursquareUser().execute(); } else if (url.contains("venue")) { new FoursquareVenue().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.mono.applink.Twitter.java
/** Called when the activity is first created. */ @Override/*w ww.j av a 2s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String url = getIntent().getData().toString(); if (url.contains("twitter.com") && !url.contains("status") && !url.contains("direct_messages") && !url.contains("user_spam_reports") && !url.contains("account") && !url.contains("settings"))//Just if it is a link of a user profile { new TwitterUser().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:com.googlecode.android_scripting.facade.ui.AlertDialogTask.java
private Builder addOnCancelListener(final AlertDialog.Builder builder, final Activity activity) { return builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { mResultMap.put("canceled", true); setResult();// w w w . ja va 2s.co m } }); }
From source file:mobisocial.musubi.social.QRInviteDialog.java
private void showErrorMessage(int message) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(message);//from ww w . j av a 2 s.co m builder.setPositiveButton(R.string.button_ok, new FinishListener(getActivity())); builder.setOnCancelListener(new FinishListener(getActivity())); builder.show(); }
From source file:nf.frex.android.FrexActivity.java
public static void showYesNoDialog(Context context, int titleId, String message, DialogInterface.OnClickListener yesListener, DialogInterface.OnClickListener noListener, DialogInterface.OnCancelListener cancelListener) { TextView textView = new TextView(context); textView.setSingleLine(false);/*www . j ava2 s .c o m*/ textView.setPadding(10, 10, 10, 10); textView.setText(message); AlertDialog.Builder b = new AlertDialog.Builder(context); b.setTitle(titleId); b.setView(textView); b.setCancelable(true); if (yesListener != null) { b.setPositiveButton(android.R.string.yes, yesListener); } if (noListener != null) { b.setNegativeButton(android.R.string.no, noListener); } if (cancelListener != null) { b.setOnCancelListener(cancelListener); } b.show(); }
From source file:com.owncloud.android.CrashlogSendActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id == DIALOG_SUBMIT) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.crashlog_message); builder.setNegativeButton(R.string.crashlog_dont_send_report, this); builder.setPositiveButton(R.string.crashlog_send_report, this); builder.setCancelable(true);/*w w w . j a va 2 s. com*/ builder.setOnCancelListener(this); return builder.create(); } return super.onCreateDialog(id); }
From source file:com.company.millenium.iwannask.MainActivity.java
public static void showNoConnectionDialog(Context ctx1) { final Context ctx = ctx1; AlertDialog.Builder builder = new AlertDialog.Builder(ctx, R.style.AlertDialog); builder.setCancelable(true);// w ww.j av a 2s. c o m builder.setMessage(R.string.no_connection); builder.setTitle(R.string.no_connection_title); builder.setPositiveButton(R.string.settings_button_text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { ctx.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); } }); builder.setNegativeButton(R.string.cancel_button_text, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { return; } }); builder.show(); }
From source file:net.sourceforge.servestream.utils.SleepTimerDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { int MAX_SLEEP_TIMER_MINUTES = 120; LayoutInflater factory = LayoutInflater.from(getActivity()); final View sleepTimerView = factory.inflate(R.layout.alert_dialog_sleep_timer, null); final TextView sleepTimerText = (TextView) sleepTimerView.findViewById(R.id.sleep_timer_text); final SeekBar seekbar = (SeekBar) sleepTimerView.findViewById(R.id.seekbar); sleepTimerText.setText(makeTimeString(mSleepTimerMode)); seekbar.setProgress(mSleepTimerMode); seekbar.setMax(MAX_SLEEP_TIMER_MINUTES); seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override/*from w ww.j a va2s . c o m*/ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { sleepTimerText.setText(makeTimeString(progress)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // Use the Builder class for convenient dialog construction AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.sleep_timer_label); builder.setCancelable(true); builder.setView(sleepTimerView); builder.setOnCancelListener(this); builder.setPositiveButton(R.string.enable_sleeptimer_label, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mListener.onSleepTimerSet(SleepTimerDialog.this, seekbar.getProgress()); } }); return builder.create(); }
From source file:com.mono.applink.Facebook.java
/** Called when the activity is first created. */ @Override// w w w.j a v a2s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = this; final String url = getIntent().getData().toString(); if (url.contains("posts") || url.contains("profile.php") || (!url.contains("&") && !url.contains("=") && url.length() > 24)) //1)Posts->It is impossible to launch FeedbackActivity because of permission denied. //With root permission and "am start" it's impossible to pass a Long extra_key... //2)Profile //3)Nickname { new FacebookUser().execute(); } else if (url.contains("sk=inbox"))//Message { new FacebookMessage().execute(); } else if (url.contains("event.php"))//event { new FacebookEvent().execute(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Sorry, but this type of link is not currently supported"); builder.setOnCancelListener(new OnCancelListener() { public void onCancel(DialogInterface dialog) { finish(); } }); builder.setPositiveButton("Open in Browser", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); i.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity")); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setData(Uri.parse(url)); startActivity(i); finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }
From source file:org.fdroid.fdroid.installer.ErrorDialogActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Intent intent = getIntent(); final String title = intent.getStringExtra(EXTRA_TITLE); final String message = intent.getStringExtra(EXTRA_MESSAGE); // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId()); final AlertDialog.Builder builder = new AlertDialog.Builder(theme); builder.setTitle(title);//from www . j a v a 2 s .c o m builder.setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setResult(Activity.RESULT_OK); finish(); } }); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { setResult(Activity.RESULT_CANCELED); finish(); } }); builder.setMessage(message); builder.create().show(); }