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:com.buddi.client.dfu.DfuActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (resultCode != RESULT_OK)
        return;/* w ww. j  ava  2  s  . c  o  m*/

    switch (requestCode) {
    case SELECT_FILE_REQ:
        // clear previous data
        mFileType = mFileTypeTmp;
        mFilePath = null;
        mFileStreamUri = null;

        // and read new one
        final Uri uri = data.getData();
        /*
         * The URI returned from application may be in 'file' or 'content' schema.
         * 'File' schema allows us to create a File object and read details from if directly.
         * Data from 'Content' schema must be read by Content Provider. To do that we are using a Loader.
         */
        if (uri.getScheme().equals("file")) {
            // the direct path to the file has been returned
            final String path = uri.getPath();
            final File file = new File(path);
            mFilePath = path;

            updateFileInfo(file.getName(), file.length(), mFileType);
        } else if (uri.getScheme().equals("content")) {
            // an Uri has been returned
            mFileStreamUri = uri;
            // if application returned Uri for streaming, let's us it. Does it works?
            // FIXME both Uris works with Google Drive app. Why both? What's the difference? How about other apps like DropBox?
            final Bundle extras = data.getExtras();
            if (extras != null && extras.containsKey(Intent.EXTRA_STREAM))
                mFileStreamUri = extras.getParcelable(Intent.EXTRA_STREAM);

            // file name and size must be obtained from Content Provider
            final Bundle bundle = new Bundle();
            bundle.putParcelable(EXTRA_URI, uri);
            //getSupportLoaderManager().restartLoader(0, bundle, this);
            getLoaderManager().restartLoader(0, bundle, this);
        }
        break;
    default:
        break;
    }
}

From source file:com.fa.imaged.activity.DetailActivityV2.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.detail_like:
        if (detailImageLoaderv2.user_has_liked) {
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0);
            liker.execute();/*from  ww w.j a v a2 s.  c  om*/
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (!detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));
        } else {
            animatePhotoLike();
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0);
            liker.execute();
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));

        }
        break;
    case R.id.detail_likeCounts:
        Intent i = new Intent(getBaseContext(), LikersActivity.class);
        i.putExtra("media_id", detailImageLoaderv2.id);
        i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")");
        startActivity(i);
        break;
    case R.id.detail_share:
        Intent shareIntent = new Intent();
        Uri uri = null;

        // Create share intent as described above
        if (!detailImageLoaderv2.video) {
            Drawable mDrawable = detailImageV2.getDrawable();
            Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap();
            String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name,
                    detailImageLoaderv2.caption);
            uri = Uri.parse(path);
        } else {

        }
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        shareIntent.putExtra(Intent.EXTRA_TEXT, detailImageLoaderv2.caption
                + getResources().getString(R.string.share_postby) + detailImageLoaderv2.username);
        startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.share_to)));
        break;
    case R.id.detail_user_pic:
        viewProfile(this, detailImageLoaderv2);

    }

}

From source file:de.baumann.browser.helper.helper_main.java

public static void openFilePicker(final Activity activity, final View view, final String startDir) {

    new ChooserDialog().with(activity).withStartFile(startDir).withChosenListener(new ChooserDialog.Result() {
        @Override//ww  w .j a  v a  2 s  .co m
        public void onChoosePath(final File pathFile) {

            final String fileExtension = pathFile.getAbsolutePath()
                    .substring(pathFile.getAbsolutePath().lastIndexOf("."));
            final String fileName = pathFile.getAbsolutePath()
                    .substring(pathFile.getAbsolutePath().lastIndexOf("/") + 1);
            final String fileNameWE = fileName.substring(0, fileName.lastIndexOf("."));

            final CharSequence[] options = { activity.getString(R.string.choose_menu_1),
                    activity.getString(R.string.choose_menu_2), activity.getString(R.string.choose_menu_3),
                    activity.getString(R.string.choose_menu_4) };

            final AlertDialog.Builder dialog = new AlertDialog.Builder(activity);
            dialog.setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.cancel();
                }
            });
            dialog.setItems(options, new DialogInterface.OnClickListener() {
                @SuppressWarnings("ResultOfMethodCallIgnored")
                @Override
                public void onClick(DialogInterface dialog, int item) {
                    if (options[item].equals(activity.getString(R.string.choose_menu_1))) {

                        String text = (activity.getString(R.string.toast_extension) + ": " + fileExtension);

                        switch (fileExtension) {
                        case ".gif":
                        case ".bmp":
                        case ".tiff":
                        case ".svg":
                        case ".png":
                        case ".jpg":
                        case ".jpeg":
                            helper_main.openFile(activity, pathFile, "image/*", view);
                            break;
                        case ".m3u8":
                        case ".mp3":
                        case ".wma":
                        case ".midi":
                        case ".wav":
                        case ".aac":
                        case ".aif":
                        case ".amp3":
                        case ".weba":
                            helper_main.openFile(activity, pathFile, "audio/*", view);
                            break;
                        case ".mpeg":
                        case ".mp4":
                        case ".ogg":
                        case ".webm":
                        case ".qt":
                        case ".3gp":
                        case ".3g2":
                        case ".avi":
                        case ".f4v":
                        case ".flv":
                        case ".h261":
                        case ".h263":
                        case ".h264":
                        case ".asf":
                        case ".wmv":
                            helper_main.openFile(activity, pathFile, "video/*", view);
                            break;
                        case ".rtx":
                        case ".csv":
                        case ".txt":
                        case ".vcs":
                        case ".vcf":
                        case ".css":
                        case ".ics":
                        case ".conf":
                        case ".config":
                        case ".java":
                            helper_main.openFile(activity, pathFile, "text/*", view);
                            break;
                        case ".html":
                            helper_main.openFile(activity, pathFile, "text/html", view);
                            break;
                        case ".apk":
                            helper_main.openFile(activity, pathFile, "application/vnd.android.package-archive",
                                    view);
                            break;
                        case ".pdf":
                            helper_main.openFile(activity, pathFile, "application/pdf", view);
                            break;
                        case ".doc":
                            helper_main.openFile(activity, pathFile, "application/msword", view);
                            break;
                        case ".xls":
                            helper_main.openFile(activity, pathFile, "application/vnd.ms-excel", view);
                            break;
                        case ".ppt":
                            helper_main.openFile(activity, pathFile, "application/vnd.ms-powerpoint", view);
                            break;
                        case ".docx":
                            helper_main.openFile(activity, pathFile,
                                    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                                    view);
                            break;
                        case ".pptx":
                            helper_main.openFile(activity, pathFile,
                                    "application/vnd.openxmlformats-officedocument.presentationml.presentation",
                                    view);
                            break;
                        case ".xlsx":
                            helper_main.openFile(activity, pathFile,
                                    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", view);
                            break;
                        case ".odt":
                            helper_main.openFile(activity, pathFile, "application/vnd.oasis.opendocument.text",
                                    view);
                            break;
                        case ".ods":
                            helper_main.openFile(activity, pathFile,
                                    "application/vnd.oasis.opendocument.spreadsheet", view);
                            break;
                        case ".odp":
                            helper_main.openFile(activity, pathFile,
                                    "application/vnd.oasis.opendocument.presentation", view);
                            break;
                        case ".zip":
                            helper_main.openFile(activity, pathFile, "application/zip", view);
                            break;
                        case ".rar":
                            helper_main.openFile(activity, pathFile, "application/x-rar-compressed", view);
                            break;
                        case ".epub":
                            helper_main.openFile(activity, pathFile, "application/epub+zip", view);
                            break;
                        case ".cbz":
                            helper_main.openFile(activity, pathFile, "application/x-cbz", view);
                            break;
                        case ".cbr":
                            helper_main.openFile(activity, pathFile, "application/x-cbr", view);
                            break;
                        case ".fb2":
                            helper_main.openFile(activity, pathFile, "application/x-fb2", view);
                            break;
                        case ".rtf":
                            helper_main.openFile(activity, pathFile, "application/rtf", view);
                            break;
                        case ".opml":
                            helper_main.openFile(activity, pathFile, "application/opml", view);
                            break;

                        default:
                            Toast.makeText(activity, text, Toast.LENGTH_SHORT).show();
                            break;
                        }

                        String dir = pathFile.getParentFile().getAbsolutePath();
                        helper_main.openFilePicker(activity, view, dir);
                    }
                    if (options[item].equals(activity.getString(R.string.choose_menu_2))) {

                        if (pathFile.exists()) {
                            Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                            sharingIntent.setType("image/png");
                            sharingIntent.putExtra(Intent.EXTRA_SUBJECT, fileName);
                            sharingIntent.putExtra(Intent.EXTRA_TEXT, fileName);
                            Uri bmpUri = Uri.fromFile(pathFile);
                            sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
                            activity.startActivity(Intent.createChooser(sharingIntent,
                                    (activity.getString(R.string.app_share_file))));
                        }
                        String dir = pathFile.getParentFile().getAbsolutePath();
                        helper_main.openFilePicker(activity, view, dir);
                    }
                    if (options[item].equals(activity.getString(R.string.choose_menu_4))) {
                        final AlertDialog.Builder dialog2 = new AlertDialog.Builder(activity);

                        dialog2.setMessage(activity.getString(R.string.choose_delete));
                        dialog2.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                pathFile.delete();
                                new Handler().postDelayed(new Runnable() {
                                    public void run() {
                                        String dir = pathFile.getParentFile().getAbsolutePath();
                                        helper_main.openFilePicker(activity, view, dir);
                                    }
                                }, 500);
                            }
                        });
                        dialog2.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                dialog.cancel();
                            }
                        });
                        dialog2.setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                // dialog dismiss without button press
                                String dir = pathFile.getParentFile().getAbsolutePath();
                                helper_main.openFilePicker(activity, view, dir);
                            }
                        });
                        dialog2.show();
                    }
                    if (options[item].equals(activity.getString(R.string.choose_menu_3))) {

                        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                        View dialogView = View.inflate(activity, R.layout.dialog_edit_file, null);

                        final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title);

                        builder.setView(dialogView);
                        builder.setTitle(R.string.choose_title);
                        builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {

                                String inputTag = edit_title.getText().toString().trim();

                                File dir = pathFile.getParentFile();
                                File to = new File(dir, inputTag + fileExtension);

                                pathFile.renameTo(to);
                                pathFile.delete();

                                new Handler().postDelayed(new Runnable() {
                                    public void run() {
                                        String dir = pathFile.getParentFile().getAbsolutePath();
                                        helper_main.openFilePicker(activity, view, dir);
                                    }
                                }, 500);
                            }
                        });
                        builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                            public void onClick(DialogInterface dialog, int whichButton) {
                                dialog.cancel();
                            }
                        });
                        builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                // dialog dismiss without button press
                                String dir = pathFile.getParentFile().getAbsolutePath();
                                helper_main.openFilePicker(activity, view, dir);
                            }
                        });

                        final AlertDialog dialog2 = builder.create();
                        // Display the custom alert dialog on interface
                        dialog2.show();
                        helper_editText.showKeyboard(activity, edit_title, 0, fileNameWE,
                                activity.getString(R.string.choose_hint));
                    }
                }
            });
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    // dialog dismiss without button press
                    String dir = pathFile.getParentFile().getAbsolutePath();
                    helper_main.openFilePicker(activity, view, dir);
                }
            });
            dialog.show();
        }
    }).build().show();
}

From source file:link.kjr.file_manager.MainActivity.java

public void sendSingleFile(String path) {

    Intent i = new Intent();
    ArrayList<Uri> files = new ArrayList<>();
    files.add(Uri.fromFile(new File(path)));
    i.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
    i.setType("*/*");
    i.setAction(Intent.ACTION_SEND_MULTIPLE);
    startActivity(Intent.createChooser(i, getString(R.string.send_file)));

}

From source file:com.kd.filmstrip.DetailActivityV2.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.detail_like:
        if (detailImageLoaderv2.user_has_liked) {
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, false, 0);
            liker.execute();//from  w  w  w . j a v  a 2  s  .co m
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (!detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(0, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));
        } else {
            animatePhotoLike();
            HeartPostTask liker = new HeartPostTask(detailImageLoaderv2, true, 0);
            liker.execute();
            try {
                detailImageLoaderv2 = liker.get();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (ExecutionException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (detailImageLoaderv2.user_has_liked) {
                Drawable myIcon = getResources().getDrawable(R.drawable.ic_like);
                myIcon.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);
                detailLikeStatus.setImageDrawable(myIcon);
            }
            detailLikeCounts.setText(String.valueOf(detailImageLoaderv2.liker_count));

        }
        break;
    case R.id.detail_likeCounts:
        Intent i = new Intent(getBaseContext(), LikersActivity.class);
        i.putExtra("media_id", detailImageLoaderv2.id);
        i.putExtra("title", "Likers " + "(" + detailImageLoaderv2.liker_count + ")");
        startActivity(i);
        break;
    case R.id.detail_share:
        Intent shareIntent = new Intent();
        Uri uri = null;

        // Create share intent as described above
        if (!detailImageLoaderv2.video) {
            Drawable mDrawable = detailImageV2.getDrawable();
            Bitmap mBitmap = ((BitmapDrawable) mDrawable).getBitmap();
            String path = Images.Media.insertImage(getContentResolver(), mBitmap, detailImageLoaderv2.full_name,
                    detailImageLoaderv2.caption);
            uri = Uri.parse(path);
        } else {

        }
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        shareIntent.putExtra(Intent.EXTRA_TEXT,
                detailImageLoaderv2.caption + " Posted by @" + detailImageLoaderv2.username);
        startActivity(Intent.createChooser(shareIntent, "Share To"));
        break;
    case R.id.detail_user_pic:
        viewProfile(this, detailImageLoaderv2);

    }

}

From source file:com.metinkale.prayerapp.vakit.fragments.MainFragment.java

private void export(int csvpdf, LocalDate from, LocalDate to) throws IOException {
    File outputDir = getActivity().getCacheDir();
    if (!outputDir.exists())
        outputDir.mkdirs();/*from   w w  w . j a v  a  2s.c  om*/
    File outputFile = new File(outputDir, mTimes.getName().replace(" ", "_") + (csvpdf == 0 ? ".csv" : ".pdf"));
    if (outputDir.exists())
        outputFile.delete();
    FileOutputStream outputStream;

    outputStream = new FileOutputStream(outputFile);
    if (csvpdf == 0) {
        outputStream.write("Date;Fajr;Shuruq;Dhuhr;Asr;Maghrib;Ishaa\n".getBytes());

        do {
            outputStream.write((from.toString("yyyy-MM-dd") + ";").getBytes());
            outputStream.write((mTimes.getTime(from, 0) + ";").getBytes());
            outputStream.write((mTimes.getTime(from, 1) + ";").getBytes());
            outputStream.write((mTimes.getTime(from, 2) + ";").getBytes());
            outputStream.write((mTimes.getTime(from, 3) + ";").getBytes());
            outputStream.write((mTimes.getTime(from, 4) + ";").getBytes());
            outputStream.write((mTimes.getTime(from, 5) + "\n").getBytes());
        } while (!(from = from.plusDays(1)).isAfter(to));
        outputStream.close();

    } else {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            PdfDocument document = new PdfDocument();

            PdfDocument.PageInfo pageInfo = null;
            int pw = 595;
            int ph = 842;
            pageInfo = new PdfDocument.PageInfo.Builder(pw, ph, 1).create();
            PdfDocument.Page page = document.startPage(pageInfo);
            Drawable launcher = Drawable.createFromStream(getActivity().getAssets().open("pdf/launcher.png"),
                    null);
            Drawable qr = Drawable.createFromStream(getActivity().getAssets().open("pdf/qrcode.png"), null);
            Drawable badge = Drawable.createFromStream(
                    getActivity().getAssets().open("pdf/badge_" + Prefs.getLanguage() + ".png"), null);

            launcher.setBounds(30, 30, 30 + 65, 30 + 65);
            qr.setBounds(pw - 30 - 65, 30 + 65 + 5, pw - 30, 30 + 65 + 5 + 65);
            int w = 100;
            int h = w * badge.getIntrinsicHeight() / badge.getIntrinsicWidth();
            badge.setBounds(pw - 30 - w, 30 + (60 / 2 - h / 2), pw - 30, 30 + (60 / 2 - h / 2) + h);

            Canvas canvas = page.getCanvas();

            Paint paint = new Paint();
            paint.setARGB(255, 0, 0, 0);
            paint.setTextSize(10);
            paint.setTextAlign(Paint.Align.CENTER);
            canvas.drawText("com.metinkale.prayer", pw - 30 - w / 2, 30 + (60 / 2 - h / 2) + h + 10, paint);

            launcher.draw(canvas);
            qr.draw(canvas);
            badge.draw(canvas);

            paint.setARGB(255, 61, 184, 230);
            canvas.drawRect(30, 30 + 60, pw - 30, 30 + 60 + 5, paint);

            if (mTimes.getSource().resId != 0) {
                Drawable source = getResources().getDrawable(mTimes.getSource().resId);

                h = 65;
                w = h * source.getIntrinsicWidth() / source.getIntrinsicHeight();
                source.setBounds(30, 30 + 65 + 5, 30 + w, 30 + 65 + 5 + h);
                source.draw(canvas);
            }

            paint.setARGB(255, 0, 0, 0);
            paint.setTextSize(40);
            paint.setTextAlign(Paint.Align.LEFT);
            canvas.drawText(getText(R.string.appName).toString(), 30 + 65 + 5, 30 + 50, paint);
            paint.setTextAlign(Paint.Align.CENTER);
            paint.setFakeBoldText(true);
            canvas.drawText(mTimes.getName(), pw / 2.0f, 30 + 65 + 50, paint);

            paint.setTextSize(12);
            int y = 30 + 65 + 5 + 65 + 30;
            int p = 30;
            int cw = (pw - p - p) / 7;
            canvas.drawText(getString(R.string.date), 30 + (0.5f * cw), y, paint);
            canvas.drawText(Vakit.IMSAK.getString(), 30 + (1.5f * cw), y, paint);
            canvas.drawText(Vakit.GUNES.getString(), 30 + (2.5f * cw), y, paint);
            canvas.drawText(Vakit.OGLE.getString(), 30 + (3.5f * cw), y, paint);
            canvas.drawText(Vakit.IKINDI.getString(), 30 + (4.5f * cw), y, paint);
            canvas.drawText(Vakit.AKSAM.getString(), 30 + (5.5f * cw), y, paint);
            canvas.drawText(Vakit.YATSI.getString(), 30 + (6.5f * cw), y, paint);
            paint.setFakeBoldText(false);
            do {
                y += 20;
                canvas.drawText((from.toString("dd.MM.yyyy")), 30 + (0.5f * cw), y, paint);
                canvas.drawText((mTimes.getTime(from, 0)), 30 + (1.5f * cw), y, paint);
                canvas.drawText((mTimes.getTime(from, 1)), 30 + (2.5f * cw), y, paint);
                canvas.drawText((mTimes.getTime(from, 2)), 30 + (3.5f * cw), y, paint);
                canvas.drawText((mTimes.getTime(from, 3)), 30 + (4.5f * cw), y, paint);
                canvas.drawText((mTimes.getTime(from, 4)), 30 + (5.5f * cw), y, paint);
                canvas.drawText((mTimes.getTime(from, 5)), 30 + (6.5f * cw), y, paint);
            } while (!(from = from.plusDays(1)).isAfter(to));
            document.finishPage(page);

            document.writeTo(outputStream);

            // close the document
            document.close();

        } else {
            Toast.makeText(getActivity(), R.string.versionNotSupported, Toast.LENGTH_LONG).show();
        }
    }

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType(csvpdf == 0 ? "text/csv" : "application/pdf");

    Uri uri = FileProvider.getUriForFile(getActivity(), "com.metinkale.prayer.fileprovider", outputFile);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

    startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.export)));
}

From source file:ch.luklanis.esscan.history.HistoryActivity.java

private Intent createShareIntent(String mime, Uri dtaFileUri) {
    String[] recipients = new String[] { PreferenceManager.getDefaultSharedPreferences(this)
            .getString(PreferencesActivity.KEY_EMAIL_ADDRESS, "") };
    String subject = getResources().getString(R.string.history_share_as_dta_title);
    String text = String.format(getResources().getString(R.string.history_share_as_dta_summary),
            dtaFileUri.getPath());// w w w .  j a va 2  s  . c om

    Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.setType(mime);

    intent.putExtra(Intent.EXTRA_EMAIL, recipients);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);

    intent.putExtra(Intent.EXTRA_STREAM, dtaFileUri);

    return intent;
}

From source file:com.cerema.cloud2.files.FileOperationsHelper.java

public void sendDownloadedFile(OCFile file) {
    if (file != null) {
        String storagePath = file.getStoragePath();
        String encodedStoragePath = WebdavUtils.encodePath(storagePath);
        Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
        // set MimeType
        sendIntent.setType(file.getMimetype());
        sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath));
        sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action

        // Show dialog, without the own app
        String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
        DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude);
        chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);

    } else {/*from   w  w w  .j  av a2 s. co  m*/
        Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
    }
}

From source file:de.k3b.android.toGoZip.SettingsActivity.java

private boolean onCmdSend(CharSequence title) {
    ZipStorage storage = SettingsImpl.getCurrentZipStorage(this);
    Intent intent = new Intent(Intent.ACTION_SEND);
    Uri contentUri = Uri.parse(storage.getFullZipUriOrNull());
    String mime = "application/zip";

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_FORWARD_RESULT
            | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);

    // EXTRA_CC, EXTRA_BCC
    // intent.putExtra(Intent.EXTRA_EMAIL, new String[]{toAddress});

    intent.putExtra(Intent.EXTRA_SUBJECT, SettingsImpl.getZipFile());

    // intent.putExtra(Intent.EXTRA_TEXT, body);

    intent.putExtra(Intent.EXTRA_STREAM, contentUri);

    intent.setType(mime);/*from www .  j  a  v a  2s  .  c om*/

    final String debugMessage = "SettingsActivity.onCmdSend(" + title + ", startActivity='" + intent.toUri(0)
            + "')";
    try {
        final Intent chooser = Intent.createChooser(intent, title);
        chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
        this.startActivity(chooser);
        if (Global.debugEnabled) {
            Log.d(Global.LOG_CONTEXT, debugMessage);
        }
    } catch (Exception ex) {
        Log.w(Global.LOG_CONTEXT, debugMessage, ex);
    }

    return true;
}

From source file:link.kjr.file_manager.MainActivity.java

public void send(MenuItem item) {
    ArrayList<Uri> files = new ArrayList<>();
    for (String file : selectedFiles) {

        files.add(Uri.fromFile(new File(file)));
    }//from  www.  ja v  a  2  s.  co  m
    Intent share = new Intent();
    share.setAction(Intent.ACTION_SEND_MULTIPLE);
    share.putParcelableArrayListExtra(Intent.EXTRA_STREAM, files);
    share.setType("*/*");
    startActivity(Intent.createChooser(share, getString(R.string.send_files)));
}