Example usage for android.app AlertDialog setOwnerActivity

List of usage examples for android.app AlertDialog setOwnerActivity

Introduction

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

Prototype

public final void setOwnerActivity(@NonNull Activity activity) 

Source Link

Document

Sets the Activity that owns this dialog.

Usage

From source file:cx.ring.client.AccountEditionActivity.java

private AlertDialog createDeleteDialog() {
    Activity ownerActivity = this;
    AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity);
    builder.setMessage("Do you really want to delete this account").setTitle("Delete Account")
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override//from  w  ww.  ja  va2  s .c  o  m
                public void onClick(DialogInterface dialog, int whichButton) {
                    Bundle bundle = new Bundle();
                    bundle.putString("AccountID", acc_selected.getAccountID());

                    try {
                        service.getRemoteService().removeAccount(acc_selected.getAccountID());
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                    finish();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    /* Terminate with no action */
                }
            });

    AlertDialog alertDialog = builder.create();
    alertDialog.setOwnerActivity(ownerActivity);

    return alertDialog;
}

From source file:eu.trentorise.smartcampus.eb.fragments.experience.EditExpFragment.java

private void onCaptureOption(final String[] elems, String[] labelElems) {
    if (elems.length > 1) {
        assert labelElems.length == elems.length;
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setItems(labelElems, new DialogInterface.OnClickListener() {
            @Override/*w w  w .ja  va 2  s.c  o  m*/
            public void onClick(DialogInterface dialog, int which) {
                startCapture(elems[which]);
                dialog.dismiss();
            }
        });
        AlertDialog dlg = builder.create();
        dlg.setOwnerActivity(getActivity());
        dlg.show();
    } else {
        startCapture(elems[0]);
    }

}

From source file:cx.ring.client.HomeActivity.java

private AlertDialog createNotRegisteredDialog() {
    final Activity ownerActivity = this;
    AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity);

    builder.setMessage(getResources().getString(R.string.cannot_pass_sipcall))
            .setTitle(getResources().getString(R.string.cannot_pass_sipcall_title)).setPositiveButton(
                    getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {

                        }/*  w ww .j  a  v  a  2  s. c  o m*/
                    });

    AlertDialog alertDialog = builder.create();
    alertDialog.setOwnerActivity(ownerActivity);

    return alertDialog;
}

From source file:cx.ring.client.HomeActivity.java

private AlertDialog createAccountDialog() {
    final Activity ownerActivity = this;
    AlertDialog.Builder builder = new AlertDialog.Builder(ownerActivity);

    builder.setMessage(getResources().getString(R.string.create_new_account_dialog))
            .setTitle(getResources().getString(R.string.create_new_account_dialog_title)).setPositiveButton(
                    getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            Intent in = new Intent();
                            in.setClass(ownerActivity, AccountWizard.class);
                            ownerActivity.startActivityForResult(in, HomeActivity.REQUEST_CODE_PREFERENCES);
                        }/*w  ww .j  av a 2 s  .c om*/
                    })
            .setNegativeButton(getResources().getString(android.R.string.cancel),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.dismiss();
                        }
                    });

    AlertDialog alertDialog = builder.create();
    alertDialog.setOwnerActivity(ownerActivity);

    return alertDialog;
}

From source file:org.bombusim.lime.fragments.RosterFragment.java

protected void showSslStatus(String certificateChain) {
    if (certificateChain == null)
        return;//w w w. j ava 2s.  com
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.sslInfo).setIcon(R.drawable.ssl_yes).setMessage(certificateChain)
            .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.setOwnerActivity(getActivity());
    alert.show();
}

From source file:org.bombusim.lime.fragments.RosterFragment.java

private void confirmDeleteContact(final Contact ctc) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(ctc.getFullName()).setIcon(new BitmapDrawable(ctc.getAvatar()))
            .setMessage(R.string.confirmDelete)
            .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    deleteContact(ctc);/*ww w  .  j  ava2 s  . c om*/
                }
            }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
    AlertDialog alert = builder.create();
    alert.setOwnerActivity(getActivity());
    alert.show();
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

/**
 * Display a dialog message TODO: make a fragment
 *
 * @param cName/*  ww w.j av  a2 s. c  om*/
 * @param resId
 */
private void displayMessage(String cName, int resId) {
    AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.loc_overlap_title)
            .setMessage(getString(resId, cName))
            .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    dialog.show();
    dialog.setOwnerActivity(this);
}

From source file:org.ohmage.triggers.types.location.LocTrigMapsActivity.java

/**
 * Display a dialog message TODO: make a fragment
 * /*  w  w w .ja  va2s  .c o m*/
 * @param cName
 * @param resId
 */
private void displayMessage(String cName, int resId) {
    AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.loc_overlap_title)
            .setMessage(getString(resId, cName))
            .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    dialog.show();
    dialog.setOwnerActivity(this);
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

public void showReminderContactsNotAvailable(Activity activity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setMessage(//from ww  w  . ja  v  a 2s  .  c om
            "This function requires the Intelligent Reminder add-on for Reminder Contacts.  Do you want to fetch it?")
            .setCancelable(false).setPositiveButton(R.string.msg_yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    if (IS_ANDROID_VERSION) {
                        String uri = "market://details?id=com.mibr.android.remindercontacts";
                        Intent ii3 = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                        startActivity(ii3);
                    } else {
                        Uri uri = Uri.parse(
                                "http://www.amazon.com/gp/mas/dl/android?p=com.mibr.android.remindercontacts");
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        startActivity(intent);
                    }
                }
            }).setNegativeButton(R.string.msg_cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub

                }
            });
    AlertDialog alert = builder.create();
    alert.setOwnerActivity(activity);
    alert.show();
}

From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java

private void showSearchResultDialog(final List<SearchResult> results) {

    if (isSearchResultsDialogShowing) {
        return;/*from w w w.  j  av  a 2s  .c  o  m*/
    }

    isSearchResultsDialogShowing = true;

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.search_results);

    SearchResultAdapter adapter = new SearchResultAdapter(context, bookView, results);
    builder.setAdapter(adapter, adapter);

    AlertDialog dialog = builder.create();
    dialog.setOwnerActivity(getActivity());
    dialog.setOnDismissListener(d -> isSearchResultsDialogShowing = false);
    dialog.show();
}