Example usage for android.content Intent EXTRA_STREAM

List of usage examples for android.content Intent EXTRA_STREAM

Introduction

In this page you can find the example usage for android.content Intent EXTRA_STREAM.

Prototype

String EXTRA_STREAM

To view the source code for android.content Intent EXTRA_STREAM.

Click Source Link

Document

A content: URI holding a stream of data associated with the Intent, used with #ACTION_SEND to supply the data being sent.

Usage

From source file:android_network.hetnet.vpn_service.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override/*from  ww w  .ja  v a 2  s .  c o m*/
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context)));
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getSubscriptionInfo(context));
            sb.append("\r\n\r\n");

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.execute();
}

From source file:eu.faircode.adblocker.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override//from  w ww  . java 2  s .c o  m
        protected Intent doInBackground(Object... objects) {
            // Get device info
            StringBuilder sb = new StringBuilder();
            String version = getSelfVersionName(context);
            sb.append(String.format("adblocker: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context)));
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getSubscriptionInfo(context));
            sb.append("\r\n\r\n");

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Finalize message
            sb.append("Please describe your problem:\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+adblocker@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.execute();
}

From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean handled = false;

    Uri trackUri;/*from w  w  w . j  a va 2 s  .  c  o  m*/
    Intent intent;
    switch (item.getItemId()) {
    case MENU_LAYERS:
        showDialog(DIALOG_LAYERS);
        handled = true;
        break;
    case MENU_NOTE:
        intent = new Intent(this, InsertNote.class);
        startActivityForResult(intent, MENU_NOTE);
        handled = true;
        break;
    case MENU_SETTINGS:
        intent = new Intent(this, SettingsActivity.class);
        startActivity(intent);
        handled = true;
        break;
    case MENU_TRACKLIST:
        intent = new Intent(this, TrackList.class);
        intent.putExtra(Tracks._ID, this.mTrackId);
        startActivityForResult(intent, MENU_TRACKLIST);
        break;
    case MENU_STATS:
        if (this.mTrackId >= 0) {
            intent = new Intent(this, Statistics.class);
            trackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, mTrackId);
            intent.setData(trackUri);
            startActivity(intent);
            handled = true;
            break;
        } else {
            showDialog(DIALOG_NOTRACK);
        }
        handled = true;
        break;
    case MENU_SHARE:
        if (this.mTrackId >= 0) {
            intent = new Intent(Intent.ACTION_RUN);
            trackUri = ContentUris.withAppendedId(Tracks.CONTENT_URI, mTrackId);
            intent.setDataAndType(trackUri, Tracks.CONTENT_ITEM_TYPE);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            Bitmap bm = findViewById(R.id.mapScreen).getDrawingCache();
            if (bm != null) {
                Uri screenStreamUri = ShareTrack.storeScreenBitmap(bm);
                intent.putExtra(Intent.EXTRA_STREAM, screenStreamUri);
            }
            startActivityForResult(Intent.createChooser(intent, getString(R.string.share_track)), MENU_SHARE);
        } else {
            showDialog(DIALOG_NOTRACK);
        }
        handled = true;
        break;
    case MENU_CONTRIB:
        showDialog(DIALOG_CONTRIB);
    default:
        handled = super.onOptionsItemSelected(item);
        break;
    }
    return handled;
}

From source file:me.tb.player.SkeletonActivity.java

private void initShareIntent(String type) {
    boolean found = false;
    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    share.setType("image/jpeg");

    // gets the list of intents that can be loaded.
    List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
    if (!resInfo.isEmpty()) {
        for (ResolveInfo info : resInfo) {
            Log.d("package name", info.activityInfo.packageName.toLowerCase());
            if (info.activityInfo.packageName.toLowerCase().contains(type)
                    || info.activityInfo.name.toLowerCase().contains(type)) {
                share.putExtra(Intent.EXTRA_SUBJECT, "subject");
                share.putExtra(Intent.EXTRA_TEXT, "your text");
                share.putExtra(Intent.EXTRA_STREAM,
                        Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/game_icon1.png"))); // Optional, just if you wanna share an image.
                share.setPackage(info.activityInfo.packageName);
                found = true;/*  w  ww.j  av  a 2 s  . c o  m*/
                break;
            }
        }
        if (!found)
            return;

        startActivity(Intent.createChooser(share, "Select"));
    }
}

From source file:com.master.metehan.filtereagle.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override/*from ww w . j a  v a2 s  .co m*/
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("FilterEagle: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context)));
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getSubscriptionInfo(context));
            sb.append("\r\n\r\n");

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "metehan.ozsoy@gmail.com" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "FilterEagle " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.execute();
}

From source file:eu.faircode.netguard.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override//from   www  . jav  a 2 s  .com
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");

            // Get DNS
            sb.append("DNS system:\r\n");
            for (String dns : getDefaultDNS(context))
                sb.append("- ").append(dns).append("\r\n");
            sb.append("DNS VPN:\r\n");
            for (InetAddress dns : ServiceSinkhole.getDns(context))
                sb.append("- ").append(dns).append("\r\n");
            sb.append("\r\n");

            // Get TCP connection info
            String line;
            BufferedReader in;
            try {
                sb.append("/proc/net/tcp:\r\n");
                in = new BufferedReader(new FileReader("/proc/net/tcp"));
                while ((line = in.readLine()) != null)
                    sb.append(line).append("\r\n");
                in.close();
                sb.append("\r\n");

                sb.append("/proc/net/tcp6:\r\n");
                in = new BufferedReader(new FileReader("/proc/net/tcp6"));
                while ((line = in.readLine()) != null)
                    sb.append(line).append("\r\n");
                in.close();
                sb.append("\r\n");

            } catch (IOException ex) {
                sb.append(ex.toString()).append("\r\n");
            }

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:com.ubuntuone.android.files.activity.FilesActivity.java

private void onSendAction(Intent intent, String resourcePath) {
    if (intent.hasExtra(Intent.EXTRA_STREAM)) {
        final Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        UpDownServiceHelper.upload(this, uri, resourcePath, false);
    }/*w  w  w. j  a va2 s.c  om*/
}

From source file:de.mkrtchyan.recoverytools.RecoveryTools.java

public void report(final boolean isCancelable) {
    final Dialog reportDialog = mNotifyer.createDialog(R.string.commentar, R.layout.dialog_comment, false,
            true);//from   w  w w  .j  a va 2s. c  om
    new Thread(new Runnable() {
        @Override
        public void run() {
            /** Creates a report Email including a Comment and important device infos */
            final Button bGo = (Button) reportDialog.findViewById(R.id.bGo);
            bGo.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {

                    if (!Common.getBooleanPref(mContext, PREF_NAME, PREF_KEY_ADS))
                        Toast.makeText(mContext, R.string.please_ads, Toast.LENGTH_SHORT).show();
                    Toast.makeText(mContext, R.string.donate_to_support, Toast.LENGTH_SHORT).show();
                    try {
                        ArrayList<File> files = new ArrayList<File>();
                        File TestResults = new File(mContext.getFilesDir(), "results.txt");
                        try {
                            if (TestResults.exists()) {
                                if (TestResults.delete()) {
                                    FileOutputStream fos = openFileOutput(TestResults.getName(),
                                            Context.MODE_PRIVATE);
                                    fos.write(("Recovery-Tools:\n\n"
                                            + mShell.execCommand(
                                                    "ls -lR " + PathToRecoveryTools.getAbsolutePath())
                                            + "\nCache Tree:\n" + mShell.execCommand("ls -lR /cache") + "\n"
                                            + "\nMTD result:\n" + mShell.execCommand("cat /proc/mtd") + "\n"
                                            + "\nDevice Tree:\n\n" + mShell.execCommand("ls -lR /dev"))
                                                    .getBytes());
                                }
                                files.add(TestResults);
                            }
                        } catch (FileNotFoundException e) {
                            e.printStackTrace();
                        }
                        if (getPackageManager() != null) {
                            PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
                            EditText text = (EditText) reportDialog.findViewById(R.id.etComment);
                            String comment = "";
                            if (text.getText() != null)
                                comment = text.getText().toString();
                            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                            intent.setType("text/plain");
                            intent.putExtra(Intent.EXTRA_EMAIL,
                                    new String[] { "ashotmkrtchyan1995@gmail.com" });
                            intent.putExtra(Intent.EXTRA_SUBJECT, "Recovery-Tools report");
                            intent.putExtra(Intent.EXTRA_TEXT, "Package Infos:" + "\n\nName: "
                                    + pInfo.packageName + "\nVersionName: " + pInfo.versionName
                                    + "\nVersionCode: " + pInfo.versionCode + "\n\n\nProduct Info: "
                                    + "\n\nManufacture: " + android.os.Build.MANUFACTURER + "\nDevice: "
                                    + Build.DEVICE + " (" + mDevice.getDeviceName() + ")" + "\nBoard: "
                                    + Build.BOARD + "\nBrand: " + Build.BRAND + "\nModel: " + Build.MODEL
                                    + "\nFingerprint: " + Build.FINGERPRINT + "\nAndroid SDK Level: "
                                    + Build.VERSION.CODENAME + " (" + Build.VERSION.SDK_INT + ")"
                                    + "\nRecovery Supported: " + mDevice.isRecoverySupported()
                                    + "\nRecovery Path: " + mDevice.getRecoveryPath() + "\nRecovery Version: "
                                    + mDevice.getRecoveryVersion() + "\nRecovery MTD: "
                                    + mDevice.isRecoveryMTD() + "\nRecovery DD: " + mDevice.isRecoveryDD()
                                    + "\nKernel Supported: " + mDevice.isKernelSupported() + "\nKernel Path: "
                                    + mDevice.getKernelPath() + "\nKernel Version: "
                                    + mDevice.getKernelVersion() + "\nKernel MTD: " + mDevice.isKernelMTD()
                                    + "\nKernel DD: " + mDevice.isKernelDD() + "\n\nCWM: "
                                    + mDevice.isCwmSupported() + "\nTWRP: " + mDevice.isTwrpSupported()
                                    + "\nPHILZ: " + mDevice.isPhilzSupported()
                                    + "\n\n\n===========COMMENT==========\n" + comment
                                    + "\n===========COMMENT END==========\n" + "\n===========PREFS==========\n"
                                    + getAllPrefs() + "\n===========PREFS END==========\n");
                            File CommandLogs = new File(mContext.getFilesDir(), Shell.Logs);
                            if (CommandLogs.exists()) {
                                files.add(CommandLogs);
                            }
                            files.add(new File(getFilesDir(), "last_log.txt"));
                            ArrayList<Uri> uris = new ArrayList<Uri>();
                            for (File file : files) {
                                mShell.execCommand("cp " + file.getAbsolutePath() + " "
                                        + new File(mContext.getFilesDir(), file.getName()).getAbsolutePath());
                                file = new File(mContext.getFilesDir(), file.getName());
                                mToolbox.setFilePermissions(file, "644");
                                uris.add(Uri.fromFile(file));
                            }
                            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
                            startActivity(Intent.createChooser(intent, "Send over Gmail"));
                            reportDialog.dismiss();
                        }
                    } catch (Exception e) {
                        reportDialog.dismiss();
                        Notifyer.showExceptionToast(mContext, TAG, e);
                    }
                }
            });
        }
    }).start();
    reportDialog.setCancelable(isCancelable);
    reportDialog.show();
}

From source file:com.ubuntuone.android.files.activity.FilesActivity.java

private void onSendMultipleAction(Intent intent, String resourcePath) {
    if (intent.hasExtra(Intent.EXTRA_STREAM)) {
        ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        for (Parcelable item : list) {
            Uri uri = (Uri) item;/* ww  w. ja v a  2s.c o m*/
            UpDownServiceHelper.upload(this, uri, resourcePath, false);
        }
    }
}

From source file:me.tb.player.SkeletonActivity.java

public void onShareClick() {
    Resources resources = getResources();
    String type = "image/*";
    String mediaPath = Environment.getExternalStorageDirectory() + "/game_icon1.png";

    // Create the URI from the media
    File media = new File(mediaPath);
    Uri uri = Uri.fromFile(media);//from   w ww  .  j a va  2  s.c o  m

    Intent emailIntent = new Intent();
    emailIntent.setAction(Intent.ACTION_SEND);
    // Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it
    emailIntent.putExtra(Intent.EXTRA_TEXT,
            "Download in Google Play Store\nhttps://play.google.com/store/apps/details?id=me.tb.player");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Play Word Bandit - Multiplayer");
    emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
    emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    emailIntent.setType(type);

    PackageManager pm = getPackageManager();
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType(type);

    Intent openInChooser = Intent.createChooser(emailIntent, resources.getString(R.string.share_chooser_text));

    List<ResolveInfo> resInfo = pm.queryIntentActivities(sendIntent, 0);
    List<LabeledIntent> intentList = new ArrayList<LabeledIntent>();
    for (int i = 0; i < resInfo.size(); i++) {
        // Extract the label, append it, and repackage it in a LabeledIntent
        ResolveInfo ri = resInfo.get(i);
        String packageName = ri.activityInfo.packageName;
        if (packageName.contains("com.google.android.gm")) {
            emailIntent.setPackage(packageName);
        } else if (packageName.contains("twitter") || packageName.contains("facebook.katana")
                || packageName.contains("com.instagram.android")) {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName(packageName, ri.activityInfo.name));
            intent.setAction(Intent.ACTION_SEND);
            intent.setType(type);
            // Add the URI and the caption to the Intent.
            intent.putExtra(Intent.EXTRA_STREAM, uri);
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

            if (packageName.contains("twitter") || packageName.contains("instagram")) {
                intent.putExtra(Intent.EXTRA_TEXT, shareMessageCombo
                        + "\nDownload now https://play.google.com/store/apps/details?id=me.tb.player");
            }
            intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon));
        }
    }

    // convert intentList to array
    LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]);

    openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
    startActivity(openInChooser);
}