Example usage for android.net Uri fromParts

List of usage examples for android.net Uri fromParts

Introduction

In this page you can find the example usage for android.net Uri fromParts.

Prototype

public static Uri fromParts(String scheme, String ssp, String fragment) 

Source Link

Document

Creates an opaque Uri from the given components.

Usage

From source file:com.github.shareme.blackandroids.greenandroid.easpermissions.AppSettingsDialog.java

private AppSettingsDialog(@NonNull final Object activityOrFragment, @NonNull final Context context,
        @NonNull String rationale, @Nullable String title, @Nullable String positiveButton,
        @Nullable String negativeButton, @Nullable DialogInterface.OnClickListener negativeListener,
        int requestCode) {

    // Create empty builder
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);

    // Set rationale
    dialogBuilder.setMessage(rationale);

    // Set title//  w w  w . j  av  a  2s  .  c o  m
    dialogBuilder.setTitle(title);

    // Positive button text, or default
    String positiveButtonText = TextUtils.isEmpty(positiveButton) ? context.getString(android.R.string.ok)
            : positiveButton;

    // Negative button text, or default
    String negativeButtonText = TextUtils.isEmpty(positiveButton) ? context.getString(android.R.string.cancel)
            : negativeButton;

    // Request code, or default
    final int settingsRequestCode = requestCode > 0 ? requestCode : DEFAULT_SETTINGS_REQ_CODE;

    // Positive click listener, launches app screen
    dialogBuilder.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Create app settings intent
            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            Uri uri = Uri.fromParts("package", context.getPackageName(), null);
            intent.setData(uri);

            // Start for result
            startForResult(activityOrFragment, intent, settingsRequestCode);
        }
    });

    // Negative click listener, dismisses dialog
    dialogBuilder.setNegativeButton(negativeButtonText, negativeListener);

    // Build dialog
    mAlertDialog = dialogBuilder.create();
}

From source file:com.mobileglobe.android.customdialer.common.CallUtil.java

/**
 * @return Uri that directly dials a user's voicemail inbox.
 *///from  w  w w  .  j  a va2 s .com
public static Uri getVoicemailUri() {
    return Uri.fromParts(PhoneAccount.SCHEME_VOICEMAIL, "", null);
}

From source file:com.slensky.focussis.fragments.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_about, container, false);

    //        ImageView logo = (ImageView) view.findViewById(R.id.image_logo);
    //        ConstraintLayout.LayoutParams lp = (ConstraintLayout.LayoutParams) logo.getLayoutParams();
    //        lp.setMargins(lp.leftMargin, ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() / 10, lp.rightMargin, lp.bottomMargin);
    //        logo.setLayoutParams(lp);

    TextView version = (TextView) view.findViewById(R.id.text_version);
    version.setText("Version " + this.version);
    //TextView copyright = (TextView) view.findViewById(R.id.text_copyright);
    //copyright.setText(String.format(getString(R.string.copyright), Calendar.getInstance().get(Calendar.YEAR)));
    //TextView license = (TextView) view.findViewById(R.id.text_license);

    ImageView mailIcon = (ImageView) view.findViewById(R.id.email_icon);
    mailIcon.setColorFilter(Color.argb(132, 0, 0, 0), PorterDuff.Mode.MULTIPLY);
    ImageView githubIcon = (ImageView) view.findViewById(R.id.github_icon);
    githubIcon.setColorFilter(Color.argb(132, 0, 0, 0), PorterDuff.Mode.MULTIPLY);
    ImageView licenseIcon = (ImageView) view.findViewById(R.id.version_icon);
    licenseIcon.setColorFilter(Color.argb(132, 0, 0, 0), PorterDuff.Mode.MULTIPLY);

    /*license.setOnClickListener(new View.OnClickListener() {
    @Override/*from  w w w  .  j a  v  a 2 s . com*/
    public void onClick(View v) {
        Uri uri = Uri.parseRequirements(getString(R.string.about_license_link));
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }
    });*/

    RelativeLayout emailLayout = (RelativeLayout) view.findViewById(R.id.email_layout);
    emailLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", getString(R.string.about_email), null));
            startActivity(Intent.createChooser(intent, "Send Email"));
        }
    });

    RelativeLayout githubLayout = (RelativeLayout) view.findViewById(R.id.github_layout);
    githubLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri.parse(getString(R.string.about_github_link));
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });

    return view;
}

From source file:com.mattprecious.notisync.fragment.SamsungTtsDialogFragment.java

private void launchAppSettings(String app) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.fromParts("package", app, null));
    startActivity(intent);//from   w ww  .  jav a2s.c  o m
}

From source file:com.brandao.tictactoe.settings.SettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);

        return true;
    }//from ww w . j  a  v a 2  s  .  com
    case R.id.menu_item_app_manager: {
        Intent intent = new Intent();
        intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null);
        intent.setData(uri);

        startActivity(intent);

        return true;
    }
    }

    return super.onOptionsItemSelected(item);
}

From source file:it.smartcampuslab.riciclo.FeedbackFragment.java

@Override
public void onStart() {
    super.onStart();
    ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle(getString(R.string.feedback_title));

    Button send = (Button) getView().findViewById(R.id.feedback_btn);
    send.setOnClickListener(new OnClickListener() {
        @Override//w  w w . j av a2  s. c o m
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", getString(R.string.feedback_to), null));
            intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject));
            String text = ((EditText) getView().findViewById(R.id.feedback_text_et)).getText().toString();
            if (RifiutiHelper.locationHelper.getLocation() != null) {
                mLocation = RifiutiHelper.locationHelper.getLocation();
                text += " \n\n[" + mLocation.getLatitude() + "," + mLocation.getLongitude() + "]";
                Log.e(getClass().getSimpleName(), "Feedback text: " + text);
            }
            intent.putExtra(Intent.EXTRA_TEXT, text);
            if (imageUri != null) {
                // intent.setType("application/image");
                intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageUri));
            }
            getActivity().startActivity(Intent.createChooser(intent, getString(R.string.feedback_mail)));
        }
    });

    OnClickListener clickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            startCamera();
        }
    };
    getView().findViewById(R.id.feedback_img).setOnClickListener(clickListener);
    getView().findViewById(R.id.feedback_img_text).setOnClickListener(clickListener);

    CheckBox check = (CheckBox) getView().findViewById(R.id.feedback_gps);
    if (check.isChecked()) {
        useLocation = true;
    }
    check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            useLocation = isChecked;
            if (isChecked) {
                // getActivity().setProgressBarIndeterminateVisibility(true);
                RifiutiHelper.locationHelper.start();
            } else {
                RifiutiHelper.locationHelper.stop();
                // getActivity().setProgressBarIndeterminateVisibility(false);
            }
        }
    });
}

From source file:com.lhr.jiandou.fragment.SettingFragment.java

@Override
public boolean onPreferenceClick(Preference preference) {
    switch (preference.getKey()) {
    case PREF_KEY_FEEDBACK:
        Intent emailintent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "13435500980@163.com", null));
        startActivity(Intent.createChooser(emailintent, ""));
        break;//from   ww  w.j  av  a2  s  .c o  m
    case PREF_KEY_PROTOCOL:
        showApacheLicenseDialog();
        break;
    case PREF_KEY_CACHE:
        ClearCacheUtils.deleteDir(getActivity().getCacheDir());
        Cache.setSummary(ClearCacheUtils.getCacheSize());
        ToastUtils.show(getActivity(), "?");
        break;
    }
    return true;
}

From source file:io.hypertrack.sendeta.util.PermissionUtils.java

public static void openSettings(Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
    intent.setData(uri);/* ww w.  jav  a2 s  .  c  o  m*/
    activity.startActivity(intent);
}

From source file:com.google.android.apps.muzei.gallery.GallerySettingsProxyActivity.java

@Override
@TargetApi(Build.VERSION_CODES.M)/*from  ww  w. ja v a  2 s  .c o  m*/
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    if (requestCode != REQUEST_READ_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE) {
        return;
    }

    if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        verifyOrRequestPermission();
    } else if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0])) {
        new AlertDialog.Builder(this, R.style.Theme_Muzei_Dialog)
                .setTitle(R.string.gallery_permission_dialog_hard_title)
                .setMessage(R.string.gallery_permission_dialog_hard_message)
                .setPositiveButton(R.string.gallery_permission_dialog_hard_positive_title,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                finish();
                                setResult(RESULT_CANCELED);
                                Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                                Uri uri = Uri.fromParts("package", getPackageName(), null);
                                intent.setData(uri);
                                startActivity(intent);
                            }
                        })
                .setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        finish();
                        setResult(RESULT_CANCELED);
                    }
                }).setNegativeButton(R.string.gallery_permission_dialog_hard_negative_title, null).show();
    } else {
        finish();
        setResult(RESULT_CANCELED);
    }
}

From source file:com.giovanniterlingen.windesheim.view.NatschoolActivity.java

public void noPermission() {
    Snackbar snackbar = Snackbar.make(view, getResources().getString(R.string.no_permission),
            Snackbar.LENGTH_LONG);/*ww  w. j  av  a  2  s .  com*/
    snackbar.setAction(getResources().getString(R.string.fix), new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            Uri uri = Uri.fromParts("package", getPackageName(), null);
            intent.setData(uri);
            startActivity(intent);
        }
    });
    snackbar.show();
}