Example usage for android.support.v4.app DialogFragment show

List of usage examples for android.support.v4.app DialogFragment show

Introduction

In this page you can find the example usage for android.support.v4.app DialogFragment show.

Prototype

public int show(FragmentTransaction transaction, String tag) 

Source Link

Document

Display the dialog, adding the fragment using an existing transaction and then committing the transaction.

Usage

From source file:com.permutassep.ui.FragmentCreatePost.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_createpost, container, false);
    getActivity().setTitle(R.string.app_main_toolbar_post_action);
    getActivity().invalidateOptionsMenu();

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }//w  w  w  .j  ava2 s.com

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager());
    mPager = (ViewPager) rootView.findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) rootView.findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) rootView.findViewById(R.id.next_button);
    mPrevButton = (Button) rootView.findViewById(R.id.prev_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (suggestDataCompletion && mCurrentPageSequence.get(mPager.getCurrentItem())
                    .getKey() == PermutaSepWizardModel.CONTACT_INFO_KEY) {

                DialogFragment dg = new DialogFragment() {
                    @Override
                    public Dialog onCreateDialog(Bundle savedInstanceState) {
                        return new AlertDialog.Builder(getActivity())
                                .setMessage(R.string.wizard_contact_suggest_data_completion_dialog_msg)
                                .setPositiveButton(R.string.submit_confirm_button,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                suggestDataCompletion = false;
                                            }
                                        })
                                .create();
                    }
                };
                dg.show(getActivity().getSupportFragmentManager(), "contact_data_dialog");

            } else if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                DialogFragment dg = new DialogFragment() {
                    @Override
                    public Dialog onCreateDialog(Bundle savedInstanceState) {
                        return new AlertDialog.Builder(getActivity())
                                .setMessage(R.string.submit_confirm_message)
                                .setPositiveButton(R.string.submit_confirm_button,
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {

                                                Post post = new Post();
                                                post.setPostDate(new Date());

                                                for (Page p : mWizardModel.getCurrentPageSequence()) {
                                                    switch (p.getKey()) {
                                                    case PermutaSepWizardModel.CONTACT_INFO_KEY:
                                                        User user = ComplexPreferences
                                                                .getComplexPreferences(getActivity(),
                                                                        Config.APP_PREFERENCES_NAME,
                                                                        Context.MODE_PRIVATE)
                                                                .getObject(PrefUtils.PREF_USER_KEY, User.class);
                                                        post.setUser(user);
                                                        break;
                                                    case PermutaSepWizardModel.CITY_FROM_KEY:
                                                        State sf = p.getData().getParcelable(
                                                                ProfessorCityFromPage.STATE_DATA_KEY);
                                                        City cf = p.getData().getParcelable(
                                                                ProfessorCityFromPage.MUNICIPALITY_DATA_KEY);
                                                        Town tf = p.getData().getParcelable(
                                                                ProfessorCityFromPage.LOCALITY_DATA_KEY);

                                                        post.setStateFrom(sf.getId());
                                                        post.setCityFrom(Short.valueOf(
                                                                String.valueOf(cf.getClaveMunicipio())));
                                                        post.setTownFrom(Short.valueOf(tf.getClave()));
                                                        post.setLatFrom(tf.getLatitud());
                                                        post.setLonFrom(tf.getLongitud());
                                                        break;
                                                    case PermutaSepWizardModel.CITY_TO_KEY:
                                                        State st = p.getData().getParcelable(
                                                                ProfessorCityToPage.STATE_TO_DATA_KEY);
                                                        City ct = p.getData().getParcelable(
                                                                ProfessorCityToPage.MUNICIPALITY_TO_DATA_KEY);
                                                        Town tt = p.getData().getParcelable(
                                                                ProfessorCityToPage.LOCALITY_TO_DATA_KEY);

                                                        post.setStateTo(st.getId());
                                                        post.setCityTo(Short.valueOf(
                                                                String.valueOf(ct.getClaveMunicipio())));
                                                        post.setTownTo(Short.valueOf(tt.getClave()));
                                                        post.setLatTo(tt.getLatitud());
                                                        post.setLonTo(tt.getLongitud());

                                                        break;
                                                    case PermutaSepWizardModel.ACADEMIC_LEVEL_KEY:
                                                        post.setAcademicLevel(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.POSITION_TYPE_KEY:
                                                        post.setPositionType(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.WORKDAY_TYPE_KEY:
                                                        post.setWorkdayType(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY));
                                                        break;
                                                    case PermutaSepWizardModel.TEACHING_CAREER_KEY:
                                                        post.setIsTeachingCareer(
                                                                p.getData().getString(p.SIMPLE_DATA_KEY)
                                                                        .equals("Si") ? true : false);
                                                        break;
                                                    case PermutaSepWizardModel.POST_TEXT_KEY:
                                                        post.setPostText(p.getData()
                                                                .getString(PostTextPage.TEXT_DATA_KEY));
                                                        break;
                                                    }
                                                }

                                                showDialog(getString(R.string.wizard_post_dlg_title),
                                                        getString(R.string.wizard_post_dlg_text));

                                                GsonBuilder gsonBuilder = new GsonBuilder()
                                                        // .registerTypeHierarchyAdapter(User.class, new UserTypeAdapter(getActivity()))
                                                        .registerTypeHierarchyAdapter(Post.class,
                                                                new PostTypeAdapter(getActivity()))
                                                        .setDateFormat(Config.APP_DATE_FORMAT);
                                                Gson gson = gsonBuilder.create();

                                                new PermutasSEPRestClient(new GsonConverter(gson)).get()
                                                        .newPost(post, new Callback<Post>() {
                                                            @Override
                                                            public void success(Post post,
                                                                    retrofit.client.Response response) {
                                                                replaceFragment();
                                                                hideDialog();
                                                            }

                                                            @Override
                                                            public void failure(RetrofitError error) {
                                                                // TODO: Add the error message dialog
                                                                hideDialog();
                                                            }
                                                        });

                                            }
                                        })
                                .setNegativeButton(android.R.string.cancel, null).create();
                    }
                };
                dg.show(getActivity().getSupportFragmentManager(), "place_order_dialog");
            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    onPageTreeChanged();
    updateBottomBar();

    return rootView;
}

From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java

public boolean handleMenuItem(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_TAKE_PHOTO: {
        takePhoto();//  ww  w. j av a 2s . c o  m
        break;
    }
    case MENU_ADD_IMAGE: {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || !openDocument()) {
            pickImage();
        }
        break;
    }
    case MENU_ADD_LOCATION: {
        final boolean attachLocation = mPreferences.getBoolean(KEY_ATTACH_LOCATION, false);
        if (!attachLocation) {
            getLocation();
        } else {
            mLocationManager.removeUpdates(this);
        }
        mPreferences.edit().putBoolean(KEY_ATTACH_LOCATION, !attachLocation).apply();
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_DRAFTS: {
        startActivity(new Intent(INTENT_ACTION_DRAFTS));
        break;
    }
    case MENU_DELETE: {
        new DeleteImageTask(this).execute();
        break;
    }
    case MENU_TOGGLE_SENSITIVE: {
        if (!hasMedia())
            return false;
        mIsPossiblySensitive = !mIsPossiblySensitive;
        setMenu();
        updateTextCount();
        break;
    }
    case MENU_VIEW: {
        if (mInReplyToStatus == null)
            return false;
        final DialogFragment fragment = new ViewStatusDialogFragment();
        final Bundle args = new Bundle();
        args.putParcelable(EXTRA_STATUS, mInReplyToStatus);
        fragment.setArguments(args);
        fragment.show(getSupportFragmentManager(), "view_status");
        break;
    }
    default: {
        break;
    }
    }
    return true;
}

From source file:ivl.android.moneybalance.ExpenseEditorActivity.java

private void pickPayer() {
    DialogFragment fragment = new DialogFragment() {
        @Override/*  w w  w . j a  va2  s  .c  o m*/
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            CharSequence[] personsArray = new CharSequence[persons.size()];
            int selected = -1;
            for (int i = 0; i < persons.size(); i++) {
                Person person = persons.get(i);
                personsArray[i] = person.getName();
                if (person.equals(expense.getPerson()))
                    selected = i;
            }

            AlertDialog.Builder builder = new AlertDialog.Builder(ExpenseEditorActivity.this);
            builder.setTitle(R.string.expense_payer_prompt);
            builder.setSingleChoiceItems(personsArray, selected, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int i) {
                    Person payer = persons.get(i);
                    expense.setPerson(payer);
                    updatePayer();
                    payerView.setError(null);
                    dismiss();
                }
            });
            return builder.create();
        }
    };
    fragment.show(getSupportFragmentManager(), "personSelector");
}

From source file:it.mb.whatshare.Dialogs.java

/**
 * Shows a dialog informing the user that Whatsapp is not installed on the
 * device, and gives an option to hide the dialog in the future.
 * /* w w  w  .ja  v  a  2  s.c o m*/
 * @param activity
 *            the caller activity
 * @param intent
 *            the intent containing the content to be shared
 */
public static void whatsappMissing(final SendToWhatsappActivity activity, final Intent intent) {
    // @formatter:off
    DialogFragment dialog = new PatchedDialogFragment() {
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            AlertDialog.Builder builder = getNoUiBuilder(activity)
                    .setTitle(activity.getString(R.string.whatsapp_not_installed_title))
                    .setMessage(activity.getString(R.string.whatsapp_not_installed)).setPositiveButton(
                            activity.getString(android.R.string.ok), new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    activity.startActivity(SendToAppActivity
                                            .createPlainIntent(intent.getStringExtra("message")));
                                }
                            })
                    .setNegativeButton(activity.getString(R.string.whatsapp_not_installed_dont_mind),
                            new DialogInterface.OnClickListener() {

                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    SharedPreferences pref = activity.getSharedPreferences("it.mb.whatshare",
                                            Context.MODE_PRIVATE);
                                    pref.edit()
                                            .putBoolean(SendToWhatsappActivity.HIDE_MISSING_WHATSAPP_KEY, true)
                                            .commit();
                                    activity.startActivity(SendToAppActivity
                                            .createPlainIntent(intent.getStringExtra("message")));
                                }
                            });
            Dialog dialog = builder.create();
            dialog.setCanceledOnTouchOutside(false);
            return dialog;
        }
    };
    dialog.show(activity.getSupportFragmentManager(), "whatsapp_missing");
    // @formatter:on
}

From source file:com.veniosg.dir.android.fragment.SimpleFileListFragment.java

private boolean handleSingleSelectionAction(ActionMode mode, MenuItem item) {
    FileHolder fItem = (FileHolder) getListAdapter().getItem(getCheckedItemPosition());
    if (fItem == null)
        return false;
    DialogFragment dialog;
    Bundle args;//from w  w  w .j  a  v  a 2s  .  com

    switch (item.getItemId()) {
    case R.id.menu_create_shortcut:
        mode.finish();
        Utils.createShortcut(fItem, getActivity());
        return true;

    case R.id.menu_move:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().cut(fItem);
        getActivity().supportInvalidateOptionsMenu();
        return true;

    case R.id.menu_copy:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().copy(fItem);
        getActivity().supportInvalidateOptionsMenu();
        return true;

    case R.id.menu_delete:
        mode.finish();
        dialog = new SingleDeleteDialog();
        dialog.setTargetFragment(SimpleFileListFragment.this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), SingleDeleteDialog.class.getName());
        return true;

    case R.id.menu_rename:
        mode.finish();
        dialog = new RenameDialog();
        dialog.setTargetFragment(SimpleFileListFragment.this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), RenameDialog.class.getName());
        return true;

    case R.id.menu_send:
        mode.finish();
        Utils.sendFile(fItem, getActivity());
        return true;

    case R.id.menu_details:
        mode.finish();
        dialog = new DetailsDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), DetailsDialog.class.getName());
        return true;

    case R.id.menu_compress:
        mode.finish();
        dialog = new SingleCompressDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelable(IntentConstants.EXTRA_DIALOG_FILE_HOLDER, fItem);
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), SingleCompressDialog.class.getName());
        return true;

    case R.id.menu_extract:
        mode.finish();
        File extractTo = new File(fItem.getFile().getParentFile(),
                FileUtils.getNameWithoutExtension(fItem.getFile()));
        extractTo.mkdirs();

        // We just extract on the current directory. If the user needs to put it in another dir,
        // he/she can copy/cut the file
        ZipService.extractTo(getActivity(), fItem, extractTo);
        return true;

    case R.id.menu_bookmark:
        mode.finish();
        addBookmark(fItem.getFile());
        return true;

    default:
        return false;
    }
}

From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java

/**
 * The user is switching to Transfer transaction type.
 */// w ww .  j av  a2 s  .  c om
private void onTransferSelected() {
    // Check whether to delete split categories, if any.
    if (hasSplitCategories()) {
        // Prompt the user to confirm deleting split categories.
        // Use DialogFragment in order to redraw the binaryDialog when switching device orientation.

        DialogFragment dialog = new YesNoDialog();
        Bundle args = new Bundle();
        args.putString("title", getContext().getString(R.string.warning));
        args.putString("message", getContext().getString(R.string.no_transfer_splits));
        args.putString("purpose", YesNoDialog.PURPOSE_DELETE_SPLITS_WHEN_SWITCHING_TO_TRANSFER);
        dialog.setArguments(args);

        dialog.show(getActivity().getSupportFragmentManager(), "tag");

        // Dialog result is handled in onEvent handlers in the listeners.

        return;
    }

    // un-check split.
    setSplit(false);

    // Set the destination account, if not already.
    if (transactionEntity.getAccountToId() == null
            || transactionEntity.getAccountToId().equals(Constants.NOT_SET)) {
        if (mAccountIdList.size() == 0) {
            // notify the user and exit.
            new MaterialDialog.Builder(getContext()).title(R.string.warning)
                    .content(R.string.no_accounts_available_for_selection).positiveText(android.R.string.ok)
                    .show();
            return;
        } else {
            transactionEntity.setAccountToId(mAccountIdList.get(0));
        }
    }

    // calculate AmountTo only if not set previously.
    if (transactionEntity.getAmountTo().isZero()) {
        Money amountTo = calculateAmountTo();
        transactionEntity.setAmountTo(amountTo);
    }
    displayAmountTo();
}

From source file:com.wit.and.dialog.manage.DialogManager.java

/**
 * <p>//from   ww  w. ja v  a  2 s  .c om
 * Invoked to show the given dialog fragment under the given tag.
 * </p>
 *
 * @param dialog    Dialog fragment to show.
 * @param dialogTag Tag under which should be the given dialog showed.
 * @return <code>True</code> if dialog was currently showed,
 * <code>false</code> if there is currently showing dialog with the
 * same tag.
 */
protected boolean onShowDialog(DialogFragment dialog, String dialogTag) {
    // Check valid dialog.
    if (dialog == null)
        return false;

    // Set parent fragment tag to be possible resolve implicit listener as
    // fragment.
    if (dialog instanceof BaseDialog) {
        ((BaseDialog) dialog).setParentFragmentTag(mParentFragmentTag);
    }

    // Correct dialog tag.
    dialogTag = (dialogTag == null) ? DIALOG_FRAGMENT_TAG : dialogTag;

    if (DEBUG)
        Log.d(TAG, "showDialog(tag('" + dialogTag + "'))");

    // Check for existing dialog fragment.
    DialogFragment currentDialog = (DialogFragment) mFragmentManager.findFragmentByTag(dialogTag);
    if (currentDialog != null) {
        if (USER_LOG)
            Log.i(TAG, String.format("Request to show dialog with tag '" + dialogTag
                    + "' failed. Dialog with this tag is already being showing. Set another tag or dismiss the previous dialog with same tag."));
        return false;
    }

    // Show dialog.
    dialog.show(mFragmentManager.beginTransaction(), dialogTag);
    return true;
}

From source file:com.veniosg.dir.android.fragment.SimpleFileListFragment.java

private boolean handleMultipleSelectionAction(ActionMode mode, MenuItem item) {
    DialogFragment dialog;
    Bundle args;/*from   w  ww.ja v  a 2  s. c o m*/
    ArrayList<FileHolder> fItems = getCheckedItems();

    switch (item.getItemId()) {
    case R.id.menu_send:
        mode.finish();
        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        ArrayList<Uri> uris = new ArrayList<Uri>();
        intent.setType("text/plain");

        for (FileHolder fh : fItems) {
            if (!fh.getFile().isDirectory())
                uris.add(FileUtils.getUri(fh));
        }

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);

        try {
            startActivity(Intent.createChooser(intent, getString(R.string.send_chooser_title)));
            return true;
        } catch (ActivityNotFoundException e) {
            Toast.makeText(getActivity(), R.string.send_not_available, Toast.LENGTH_SHORT).show();
            return true;
        }
    case R.id.menu_delete:
        mode.finish();
        dialog = new MultiDeleteDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelableArrayList(IntentConstants.EXTRA_DIALOG_FILE_HOLDER,
                new ArrayList<Parcelable>(fItems));
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), MultiDeleteDialog.class.getName());
        return true;
    case R.id.menu_move:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().cut(fItems);
        getActivity().supportInvalidateOptionsMenu();
        return true;
    case R.id.menu_copy:
        mode.finish();
        ((FileManagerApplication) getActivity().getApplication()).getCopyHelper().copy(fItems);
        getActivity().supportInvalidateOptionsMenu();
        return true;
    case R.id.menu_compress:
        mode.finish();
        dialog = new MultiCompressDialog();
        dialog.setTargetFragment(this, 0);
        args = new Bundle();
        args.putParcelableArrayList(IntentConstants.EXTRA_DIALOG_FILE_HOLDER,
                new ArrayList<Parcelable>(fItems));
        dialog.setArguments(args);
        dialog.show(getFragmentManager(), MultiCompressDialog.class.getName());
        return true;
    default:
        return false;
    }
}

From source file:com.grottworkshop.gwswizardpager.ui.ImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_page_image, container, false);
    ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle());

    imageView = (ImageView) rootView.findViewById(R.id.imageView);

    String imageData = mPage.getData().getString(Page.SIMPLE_DATA_KEY);
    if (!TextUtils.isEmpty(imageData)) {
        Uri imageUri = Uri.parse(imageData);
        imageView.setImageURI(imageUri);
    } else {/*from w  w w . j  a v a 2  s .c  o m*/
        imageView.setImageResource(R.drawable.ic_person);
    }

    imageView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            DialogFragment pickPhotoSourceDialog = new DialogFragment() {
                @NonNull
                @Override
                public Dialog onCreateDialog(Bundle savedInstanceState) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                    builder.setItems(R.array.image_photo_sources, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            switch (which) {
                            case 0:
                                // Gallery
                                Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
                                photoPickerIntent.setType("image/*");
                                startActivityForResult(photoPickerIntent, GALLERY_REQUEST_CODE);
                                break;

                            default:
                                // Camera
                                mNewImageUri = getActivity().getContentResolver().insert(
                                        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
                                Intent photoFromCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                                photoFromCamera.putExtra(MediaStore.EXTRA_OUTPUT, mNewImageUri);
                                photoFromCamera.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
                                startActivityForResult(photoFromCamera, CAMERA_REQUEST_CODE);
                                break;
                            }

                        }
                    });
                    return builder.create();
                }
            };

            pickPhotoSourceDialog.show(getFragmentManager(), "pickPhotoSourceDialog");
        }
    });

    return rootView;
}

From source file:es.gaedr_space.puntogpsqr.QRVisorFragment.java

/**
 * Mtodo que se lanza cada vez que se encuentra un resultado para su manejo
 *
 * @param result que contiene el contenido del QR
 *//*from w w w.  ja va  2 s  . c o m*/
@Override
public void handleResult(Result result) {
    try {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Ringtone r = RingtoneManager.getRingtone(getActivity().getApplicationContext(), notification);
        r.play();
    } catch (Exception e) {
        Log.d(TAG, getContext().getString(R.string.error_sound) + " : " + e.getMessage());
    }

    if (transforStringToCoordinates(result.getText())) {
        GPS = new GPSService(getActivity());
        if (GPS.canGetLocation()) {
            mSiteLocation.save();
            DialogFragment dialog = new DialogFragment() {
                @NonNull
                @Override
                public Dialog onCreateDialog(Bundle savedInstanceState) {

                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

                    builder.setMessage(getString(R.string.dialog_message, mSiteLocation.getLatitude(),
                            mSiteLocation.getLongitude()));

                    builder.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            if (!mSiteLocation.isEmpty()) {
                                startActivity(mapsLauncher(mSiteLocation, GPS.getSiteLocation()));
                            }
                            mSiteLocation = null;
                            dismiss();
                        }
                    });

                    builder.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            mSiteLocation = null;
                            dismiss();
                        }
                    });

                    builder.setCancelable(false);
                    return builder.create();
                }

                @Override
                public void onPause() {
                    mSiteLocation = null;
                    super.onPause();
                }

                @Override
                public void onDetach() {
                    mSiteLocation = null;
                    super.onDetach();
                }
            };
            dialog.show(getActivity().getSupportFragmentManager(), "dialog");
        } else {
            showSettingsAlert(getActivity());
        }
    }
    mScannerView.resumeCameraPreview(this);
}