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.pasta.mensadd.fragments.ImprintFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.feedback:
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "julianctni@gmail.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "feedback mensaDD");
        startActivity(Intent.createChooser(emailIntent, getString(R.string.send_feedback_mail)));
        return true;
    default:/*from  w w w  .j  av  a 2s  .com*/
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.nuvolect.securesuite.util.PermissionUtil.java

public static void showInstalledAppDetails(Context context) {

    if (context == null) {
        return;//from   w w w.  ja v a  2s.  c o m
    }
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", context.getPackageName(), null);
    intent.setData(uri);
    context.startActivity(intent);
}

From source file:com.github.jthuraisamy.yellowusage.ui.VoiceOverageOutgoingCallWarningDialog.java

@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();

    float totalOverageFees = OverageFeesHelper.calculateTotal(context);
    float peakTimeVoiceOverageFeePricePerMin = PreferenceHelper.getPeakTimeVoiceOverageFeePricePerMin(context);

    AlertDialog.Builder alertDialog = new AlertDialog.Builder(context);

    // Set message.
    String alertMessage = String.format(getString(R.string.voice_overage_alert_message), totalOverageFees,
            peakTimeVoiceOverageFeePricePerMin);
    alertDialog.setMessage(alertMessage);

    // Set OnClickListener for negative button.
    alertDialog.setNegativeButton(R.string.action_cancel, new DialogInterface.OnClickListener() {
        @Override//  ww  w.  j  a  v a  2 s .c om
        public void onClick(DialogInterface dialog, int i) {
            getActivity().finish();
        }
    });

    // Set OnClickListener for positive button.
    alertDialog.setPositiveButton(R.string.action_continue, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            Uri uri = Uri.fromParts("tel", phoneNumber + CallListener.IGNORE_SUFFIX, null);
            Intent intent = new Intent("android.intent.action.CALL", uri);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            getActivity().finish();
        }
    });

    return alertDialog.create();
}

From source file:com.emartynov.android.app.urlsetter.android.ui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.action_about) {
        startActivity(new Intent(this, AboutActivity.class));
        return true;
    } else if (item.getItemId() == R.id.action_feedback) {
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", "bijdorpstudio@gmail.com", null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_subject));
        startActivity(Intent.createChooser(emailIntent, getString(R.string.action_feedback)));
        return true;
    } else if (item.getItemId() == R.id.action_resolve_link) {
        FragmentManager fm = getSupportFragmentManager();
        EnterShortenedUrlFragment userInputDialog = new EnterShortenedUrlFragment();
        userInputDialog.show(fm, null);//from  w  w w . j ava 2s  . c  o  m

        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}

From source file:fr.bmartel.fadecandy.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object/*from  w w  w  .j  a v a  2 s . c  om*/
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        final IFc fcActivity) {

    switch (menuItem.getItemId()) {
    case R.id.server_status: {
        fcActivity.switchServerStatus();
        break;
    }
    case R.id.server_config: {
        if (fcActivity != null) {
            ConfigurationDialog dialog = new ConfigurationDialog(fcActivity);
            fcActivity.setCurrentDialog(dialog);
            dialog.show();
        }
        break;
    }
    case R.id.ledstrip_config: {
        if (fcActivity != null) {
            LedStripConfigurationDialog dialog = new LedStripConfigurationDialog(fcActivity);
            fcActivity.setCurrentDialog(dialog);
            dialog.show();
        }
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog dialog = new OpenSourceItemsDialog(context);
        fcActivity.setCurrentDialog(dialog);
        dialog.show();
        break;
    }
    case R.id.rate_app: {
        context.startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + context.getApplicationContext().getPackageName())));
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        fcActivity.setCurrentDialog(dialog);
        dialog.show();
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.developper_mail), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_object));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.issue_message));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.service_config: {

        CharSequence[] array = { "persistent", "non persistent" };

        int indexCheck = 0;
        if (fcActivity.getServiceType() == ServiceType.NON_PERSISTENT_SERVICE) {
            indexCheck = 1;
        }

        Dialog dialog = new AlertDialog.Builder(context).setSingleChoiceItems(array, indexCheck, null)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                        int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                        if (selectedPosition == 1) {
                            fcActivity.setServiceType(ServiceType.NON_PERSISTENT_SERVICE);
                        } else {
                            fcActivity.setServiceType(ServiceType.PERSISTENT_SERVICE);
                        }
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }
                }).show();
        fcActivity.setCurrentDialog(dialog);

        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:cw.kop.autobackground.tutorial.FinishFragment.java

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

    View view = inflater.inflate(R.layout.tutorial_finish_fragment, container, false);
    int colorFilterInt = AppSettings.getColorFilterInt(appContext);

    TextView titleText = (TextView) view.findViewById(R.id.title_text);
    titleText.setTextColor(colorFilterInt);
    titleText.setText("That's it.");

    TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text);
    tutorialText.setTextColor(colorFilterInt);
    tutorialText.setText("Now you're ready to use AutoBackground. I'd suggest adding a new source first "
            + "and then hitting download." + "\n" + "\n"
            + "If you have any questions, concerns, suggestions, or whatever else, feel free to "
            + "email me at ");
    SpannableString emailString = new SpannableString("chiuwinson@gmail.com");
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override/*w  w  w.j av a 2  s. c o m*/
        public void onClick(View widget) {
            Log.i(TAG, "Clicked");
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "chiuwinson@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "AutoBackground Feedback");
            startActivity(Intent.createChooser(emailIntent, "Send email"));
        }
    };
    emailString.setSpan(clickableSpan, 0, emailString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    tutorialText.append(emailString);
    tutorialText.append(".");
    tutorialText.setMovementMethod(LinkMovementMethod.getInstance());

    return view;
}

From source file:com.marcosedo.lagramola.HelpFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.help, container, false);

    //////////LISTVIEW, ADAPTER Y TEXTO DE LOS MENUS
    final Resources resources = getResources();
    listView = (ListView) view.findViewById(android.R.id.list);
    List<Map<String, String>> data = new ArrayList<Map<String, String>>();
    String[] titles_str = { resources.getString(R.string.appVersionTxt),
            resources.getString(R.string.feedbackMail), resources.getString(R.string.OSLicenses) };
    String[] subtitles_str = { resources.getString(R.string.appVersionNumber),
            resources.getString(R.string.myEmailAddress), "" };

    for (int i = 0; i < titles_str.length; i++) {
        Map<String, String> datum = new HashMap<String, String>(2);
        datum.put("title", titles_str[i]);
        datum.put("subtitle", subtitles_str[i]);
        data.add(datum);/*  ww  w  .  ja va  2s .co  m*/
    }

    SimpleAdapter adapter = new SimpleAdapter(getActivity(), data, android.R.layout.simple_list_item_2,
            new String[] { "title", "subtitle" }, new int[] { android.R.id.text1, android.R.id.text2 });
    listView.setAdapter(adapter);

    //LISTENER DEL LIST VIEW esto nos saca el context menu con un solo click
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View v, int position, long arg3) {

            Resources resource = getActivity().getResources();

            switch (position) {
            case 1:
                Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                        Uri.fromParts("mailto", Constantes.MY_EMAIL, null));
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
                emailIntent.putExtra(Intent.EXTRA_TEXT, "Body");
                startActivity(Intent.createChooser(emailIntent, "Enviar email..."));
                break;
            case 2:
                String LicenseInfo = resource.getString(R.string.headerOSLicenses)
                        + GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getActivity());
                AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(getActivity());
                LicenseDialog.setTitle(resource.getString(R.string.OSLicenses));

                if (LicenseInfo != null) {
                    LicenseDialog.setMessage(LicenseInfo);
                    LicenseDialog.show();
                    break;
                }
            }
        }
    });

    return view;
}

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

/**
 * Return Uri with an appropriate scheme, accepting both SIP and usual phone call
 * numbers./*from  w ww  .  j  a va 2  s . co  m*/
 */
public static Uri getCallUri(String number) {
    if (PhoneNumberHelper.isUriNumber(number)) {
        return Uri.fromParts(PhoneAccount.SCHEME_SIP, number, null);
    }
    return Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
}

From source file:com.github.fi3te.iliasdownloader.view.util.MenuItemSelectedUtil.java

public static boolean onOptionsItemSelected(final FragmentActivity activity, MenuItem item) {
    int id = item.getItemId();
    switch (id) {
    case R.id.coursesItem:
        FragmentManager fm = activity.getSupportFragmentManager();
        Fragment loadCoursesTask = new LoadCoursesDialogFragment();
        fm.beginTransaction().add(loadCoursesTask, IliasActivity.TASK_FRAGMENT_TAG).commit();
        fm.executePendingTransactions();
        return true;
    case R.id.licencesItem:
        activity.startActivity(new Intent(activity, LicensesActivity.class));
        return true;
    case R.id.imprintItem:
        DialogUtil.showImprint(activity);
        return true;
    case R.id.aboutItem:
        String version = null;//from w ww. j  a  v a 2 s .  com
        try {
            PackageInfo packageInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
            version = packageInfo.versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        final String v = (version == null) ? "" : (" " + version);
        new MaterialDialog.Builder(activity).icon(activity.getResources().getDrawable(R.mipmap.ic_launcher))
                .title(activity.getResources().getString(R.string.about))
                .content(activity.getResources().getString(R.string.app_name)
                        + ((version != null) ? (" " + version) : "") + "\n" + "Fiete Wennier" + "\n"
                        + "https://github.com/fi3te/ILIASDownloaderAndroid")
                .positiveText(activity.getResources().getString(R.string.support))
                .callback(new MaterialDialog.ButtonCallback() {
                    @Override
                    public void onPositive(MaterialDialog dialog) {
                        Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                                Uri.fromParts("mailto", "fiete.wennier@gmail.com", null));
                        emailIntent.putExtra(Intent.EXTRA_SUBJECT,
                                activity.getResources().getString(R.string.app_name) + v);
                        activity.startActivity(Intent.createChooser(emailIntent, "E-Mail"));

                        dialog.cancel();
                    }
                }).show();
        return true;
    }
    return false;
}

From source file:com.baseframe.core.permissions.AppSettingsDialog.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
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, R.style.AppDialogStyle);

    // Set rationale
    dialogBuilder.setMessage(rationale);

    // Set title/*from   w w w . j  a  v  a 2s .c om*/
    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();
}