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.android.soma.Launcher.java

boolean startApplicationUninstallActivity(ComponentName componentName, int flags) {
    if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) {
        // System applications cannot be installed. For now, show a toast explaining that.
        // We may give them the option of disabling apps this way.
        int messageId = R.string.uninstall_system_app_text;
        Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show();
        return false;
    } else {/*from   w  w w  .  jav  a 2s .c o m*/
        String packageName = componentName.getPackageName();
        String className = componentName.getClassName();
        Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        startActivity(intent);
        return true;
    }
}

From source file:com.android.mms.ui.ComposeMessageActivity.java

@Override
public void onPickup() {
    if (getRecipients().isEmpty() == false) {
        mMultiSensorManager.disable();/*from ww w. jav  a 2s.  c  o  m*/

        // get number and attach it to an Intent.ACTION_CALL, then start
        // the Intent
        String number = getRecipients().get(0).getNumber();
        Intent dialIntent = new Intent(Intent.ACTION_CALL);
        dialIntent.setData(Uri.fromParts("tel", number, null));
        dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dialIntent);
    }
}

From source file:com.zoffcc.applications.zanavi.Navit.java

void sendEmailWithAttachment(Context c, final String recipient, final String subject, final String message,
        final String full_file_name, final String full_file_name_suppl) {
    try {//w w  w.ja va 2  s  . c o m
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", recipient, null));
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        ArrayList<Uri> uris = new ArrayList<>();
        uris.add(Uri.parse("file://" + full_file_name));
        try {
            if (new File(full_file_name_suppl).length() > 0) {
                uris.add(Uri.parse("file://" + full_file_name_suppl));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(emailIntent, 0);
        List<LabeledIntent> intents = new ArrayList<>();

        if (resolveInfos.size() != 0) {
            for (ResolveInfo info : resolveInfos) {
                Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                System.out.println(
                        "email:" + "comp=" + info.activityInfo.packageName + " " + info.activityInfo.name);
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.putExtra(Intent.EXTRA_EMAIL, new String[] { recipient });
                if (subject != null)
                    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
                if (message != null)
                    intent.putExtra(Intent.EXTRA_TEXT, message);
                intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
                intents.add(new LabeledIntent(intent, info.activityInfo.packageName,
                        info.loadLabel(getPackageManager()), info.icon));
            }
            Intent chooser = Intent.createChooser(intents.remove(intents.size() - 1),
                    Navit.get_text("Send email with attachments"));
            chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents.toArray(new LabeledIntent[intents.size()]));
            startActivity(chooser);
        } else {
            System.out.println("email:" + "No Email App found");
            new AlertDialog.Builder(c).setMessage(Navit.get_text("No Email App found"))
                    .setPositiveButton(Navit.get_text("Ok"), null).show();
        }

        //         final Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", recipient, null));
        //         if (recipient != null) emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { recipient });
        //         if (subject != null) emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
        //         if (message != null) emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
        //         if (full_file_name != null)
        //         {
        //            emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + full_file_name));
        //            //ArrayList<Uri> uris = new ArrayList<>();
        //            //uris.add(Uri.parse("file://" + full_file_name));
        //            //emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); //ArrayList<Uri> of attachment Uri's
        //         }
        //
        //         List<ResolveInfo> resolveInfos = getPackageManager().queryIntentActivities(emailIntent, 0);
        //         if (resolveInfos.size() != 0)
        //         {
        //            String packageName = resolveInfos.get(0).activityInfo.packageName;
        //            String name = resolveInfos.get(0).activityInfo.name;
        //
        //            emailIntent.setAction(Intent.ACTION_SEND);
        //            emailIntent.setComponent(new ComponentName(packageName, name));
        //
        //            System.out.println("email:" + "comp=" + packageName + " " + name);
        //
        //            startActivity(emailIntent);
        //         }
        //         else
        //         {
        //            System.out.println("email:" + "No Email App found");
        //            new AlertDialog.Builder(c).setMessage(Navit.get_text("No Email App found")).setPositiveButton(Navit.get_text("Ok"), null).show();
        //         }

    } catch (ActivityNotFoundException e) {
        // cannot send email for some reason
    }
}