Example usage for android.content Intent putParcelableArrayListExtra

List of usage examples for android.content Intent putParcelableArrayListExtra

Introduction

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

Prototype

public @NonNull Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) 

Source Link

Document

Add extended data to the intent.

Usage

From source file:bupt.tiantian.callrecorder.callrecorder.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        Intent intent = new Intent(this, SettingsActivity.class);
        intent.putExtra("write_external", permissionWriteExternal);
        startActivity(intent);//from w  ww  . j a v  a  2 s  .co m
        return true;
    }

    if (id == R.id.action_save) {
        if (null != selectedItems && selectedItems.length > 0) {
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    for (PhoneCallRecord record : selectedItems) {
                        record.getPhoneCall().setKept(true);
                        record.getPhoneCall().save(MainActivity.this);
                    }
                    LocalBroadcastManager.getInstance(MainActivity.this)
                            .sendBroadcast(new Intent(LocalBroadcastActions.NEW_RECORDING_BROADCAST)); // Causes refresh

                }
            };
            handler.post(runnable);
        }
        return true;
    }

    if (id == R.id.action_share) {
        if (null != selectedItems && selectedItems.length > 0) {
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    ArrayList<Uri> fileUris = new ArrayList<Uri>();
                    for (PhoneCallRecord record : selectedItems) {
                        fileUris.add(Uri.fromFile(new File(record.getPhoneCall().getPathToRecording())));
                    }
                    Intent shareIntent = new Intent();
                    shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
                    shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUris);
                    shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_title));
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                        shareIntent.putExtra(Intent.EXTRA_HTML_TEXT,
                                Html.fromHtml(getString(R.string.email_body_html), Html.FROM_HTML_MODE_LEGACY));
                    } else {
                        shareIntent.putExtra(Intent.EXTRA_HTML_TEXT,
                                Html.fromHtml(getString(R.string.email_body_html)));
                    }
                    shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_body));
                    shareIntent.setType("audio/*");
                    startActivity(Intent.createChooser(shareIntent, getString(R.string.action_share)));
                }
            };
            handler.post(runnable);
        }
        return true;
    }

    if (id == R.id.action_delete) {
        if (null != selectedItems && selectedItems.length > 0) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle(R.string.delete_recording_title);
            alert.setMessage(R.string.delete_recording_subject);
            alert.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                            Database callLog = Database.getInstance(MainActivity.this);
                            for (PhoneCallRecord record : selectedItems) {
                                int id = record.getPhoneCall().getId();
                                callLog.removeCall(id);
                            }

                            LocalBroadcastManager.getInstance(MainActivity.this).sendBroadcast(
                                    new Intent(LocalBroadcastActions.RECORDING_DELETED_BROADCAST));
                            //?selectedItems
                            onListFragmentInteraction(new PhoneCallRecord[] {});
                        }
                    };
                    handler.post(runnable);

                    dialog.dismiss();

                }
            });
            alert.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    dialog.dismiss();
                }
            });

            alert.show();
        }
        return true;
    }

    if (id == R.id.action_delete_all) {

        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle(R.string.delete_recording_title);
        alert.setMessage(R.string.delete_all_recording_subject);
        alert.setPositiveButton(R.string.dialog_yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                Runnable runnable = new Runnable() {
                    @Override
                    public void run() {
                        Database.getInstance(MainActivity.this).removeAllCalls(false);
                        LocalBroadcastManager.getInstance(getApplicationContext())
                                .sendBroadcast(new Intent(LocalBroadcastActions.RECORDING_DELETED_BROADCAST));
                        //?selectedItems
                        onListFragmentInteraction(new PhoneCallRecord[] {});
                    }
                };
                handler.post(runnable);

                dialog.dismiss();

            }
        });
        alert.setNegativeButton(R.string.dialog_no, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
            }
        });

        alert.show();

        return true;
    }

    if (R.id.action_whitelist == id) {
        if (permissionReadContacts) {
            Intent intent = new Intent(this, WhitelistActivity.class);
            startActivity(intent);
        } else {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle(R.string.permission_whitelist_title);
            alert.setMessage(R.string.permission_whitelist);
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    destroyed = false;//from  w  w w  .j av a 2s. co  m
    if (getActionBar() != null)
        getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    Log.d("New Intent", intent.toString());
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        if (type.startsWith("image/")) {
            Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
            Intent serviceIntent = new Intent(this, UploadService.class);
            if (intent.getExtras() == null)
                finish();
            serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM"));
            startService(serviceIntent);
            finish();
        }
    } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) {
        Log.d("sending", "sending multiple");
        Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show();
        ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
        Intent serviceIntent = new Intent(this, UploadService.class);
        serviceIntent.putParcelableArrayListExtra("images", list);
        startService(serviceIntent);
        finish();
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null
            && intent.getData().toString().startsWith("http://imgur.com/a")) {
        String uri = intent.getData().toString();
        album = uri.split("/")[4];
        Log.d("album", album);
        Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
        fetcher.execute();
    } else if (Intent.ACTION_VIEW.equals(action)
            && intent.getData().toString().startsWith("http://imgur.com/gallery/")) {
        String uri = intent.getData().toString();
        final String album = uri.split("/")[4];
        if (album.length() == 5) {
            Log.d("album", album);
            Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM);
            fetcher.execute();
        } else if (album.length() == 7) {
            Log.d("image", album);
            Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE);
            fetcher.execute();
        }
    } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) {
        String uri = intent.getData().toString();
        final String image = uri.split("/")[3].split("\\.")[0];
        Log.d("image", image);
        Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE);
        fetcher.execute();
    }
}

From source file:com.example.demo_dv_fuse.DetailsTab.java

void loadGalleryData(final Intent intent) {
    final AirportMaps airportMaps = new AirportMaps();
    // airportMaps.new JSONExecutor().execute(this.flight.getDepartureAirportCode());
    airportMaps.getResults(this.flight.getDepartureAirportCode());
    final Map<String, TerminalMap> maps = airportMaps.getMap();
    //final String uriPrefix = "android.resource://" + getActivity().getPackageName() + '/'; //$NON-NLS-1$
    final ArrayList<TerminalMapParcelable> data = new ArrayList<TerminalMapParcelable>(maps.size());

    for (final TerminalMap map : maps.values()) {
        data.add(new TerminalMapParcelable(
                new TerminalMap(map.getImageName(), map.getTitle(), map.getSubtitle())));
    }/*from   w ww.ja  va  2  s.c  o  m*/

    intent.putParcelableArrayListExtra(TerminalMapParcelable.TERMINAL_MAPS, data);
}

From source file:com.mbientlab.metawear.app.LoggingFragment.java

private void startEmailIntent() {
    mwMnger.getCurrentController().removeModuleCallback(sensors[sensorIndex]);

    ArrayList<Uri> fileUris = new ArrayList<>();

    try {/* www  .j a  v a2  s  .c  o  m*/
        for (File it : sensors[sensorIndex].saveDataToFile()) {
            fileUris.add(
                    FileProvider.getUriForFile(getActivity(), "com.mbientlab.metawear.app.fileprovider", it));
        }

        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT,
                String.format(Locale.US, "Logged %s data - %tY-%<tm-%<tdT%<tH-%<tM-%<tS",
                        sensors[sensorIndex].toString(), Calendar.getInstance().getTime()));

        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, fileUris);
        startActivity(Intent.createChooser(intent, "Send email..."));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int itemID = item.getItemId();
    if (itemID == android.R.id.home) {
        materialMenu.animateTouch();//from   ww w.j  ava 2  s.com
        finish();
    } else if (itemID == R.id.menuNext) {

        //android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager();

        if (mVideoFragment != null || mImageFragment != null) {

            if (mVideoFragment != null) {
                if (mVideoFragment.getSelectedVideos() != null
                        && mVideoFragment.getSelectedVideos().size() > 0) {
                    Intent videoIntent = new Intent();
                    videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    //videoIntent.putStringArrayListExtra("list", mVideoFragment.getSelectedVideoList());
                    videoIntent.putParcelableArrayListExtra("selectedVideos",
                            mVideoFragment.getSelectedVideos());
                    setResult(RESULT_OK, videoIntent);
                    sendBroadcast(videoIntent);
                }
            }

            if (mImageFragment != null) {
                if (mImageFragment.getSelectedImages() != null
                        && mImageFragment.getSelectedImages().size() > 0) {
                    Intent imageIntent = new Intent();
                    imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    //imageIntent.putStringArrayListExtra("list", mImageFragment.getSelectedImageList());
                    imageIntent.putParcelableArrayListExtra("selectedImages",
                            mImageFragment.getSelectedImages());
                    setResult(RESULT_OK, imageIntent);
                    sendBroadcast(imageIntent);
                }
            }

            finish();

        } else {
            Toast.makeText(HomeFragmentActivity.this, getString(R.string.plaese_select_file),
                    Toast.LENGTH_SHORT).show();
        }
    } else if (itemID == R.id.menuCamera) {

        if (currentMediaMode == MediaType.VIDEO) {

            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaType.VIDEO); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
            Long limit = Long.valueOf((MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB * 1024 * 1024));
            intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit);
            intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,
                    MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND);

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

        } else {

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaType.IMAGE); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name            

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }

    }

    return super.onOptionsItemSelected(item);
}

From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int itemID = item.getItemId();
    if (itemID == android.R.id.home) {
        materialMenu.animateTouch();/*  w w w.  j a v a 2s  .  co  m*/
        finish();
    } else if (itemID == R.id.menuNext) {

        if (mSelectedImages.size() == 0 && mSelectedImages.size() == 0) {
            Toast.makeText(BucketHomeFragmentActivity.this, getString(R.string.plaese_select_file),
                    Toast.LENGTH_SHORT).show();

        } else {

            if (mSelectedVideos.size() > 0) {
                Intent videoIntent = new Intent();
                videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                //videoIntent.putStringArrayListExtra("list", mSelectedVideo);
                videoIntent.putParcelableArrayListExtra("selectedVideos", mSelectedVideos);
                setResult(RESULT_OK, videoIntent);
                sendBroadcast(videoIntent);
            }

            if (mSelectedImages.size() > 0) {
                Intent imageIntent = new Intent();
                imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                //imageIntent.putStringArrayListExtra("list", mSelectedImage);
                imageIntent.putParcelableArrayListExtra("selectedImages", mSelectedImages);
                setResult(RESULT_OK, imageIntent);
                sendBroadcast(imageIntent);
            }
            finish();
        }
    } else if (itemID == R.id.menuCamera) {

        if (currentMediaMode == MediaType.VIDEO) {

            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

            // create a file to save the image
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO);

            //fileUri = getVideoInMediaStore(fileUri);

            // set the image file name
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
            intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
            Long limit = Long.valueOf((MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB * 1024 * 1024));
            intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit);
            intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,
                    MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND);

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

        } else {

            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

            // create a file to save the image
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE);

            // set the image file name
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }

    }

    return super.onOptionsItemSelected(item);
}

From source file:com.krayzk9s.imgurholo.ui.ImagesFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection
    final Activity activity = getActivity();
    switch (item.getItemId()) {
    case R.id.action_download:
        Toast.makeText(activity,// www  .  java  2s .c  om
                String.format(getActivity().getResources().getString(R.string.toast_downloading), urls.size()),
                Toast.LENGTH_SHORT).show();
        Intent serviceIntent = new Intent(activity, DownloadService.class);
        serviceIntent.putParcelableArrayListExtra("ids", ids);
        if (albumId != null)
            serviceIntent.putExtra("albumName", albumId);
        else
            serviceIntent.putExtra("albumName", imageCall);
        activity.startService(serviceIntent);
        return true;
    case R.id.action_refresh:
        urls = new ArrayList<String>();
        ids = new ArrayList<JSONParcelable>();
        page = 0;
        makeGallery();
        return true;
    case R.id.action_copy:
        ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData clip = ClipData.newPlainText("imgur Link", "http://imgur.com/a/" + albumId);
        clipboard.setPrimaryClip(clip);
        Toast.makeText(activity, R.string.toast_copied, Toast.LENGTH_SHORT).show();
        return true;
    case R.id.action_share:
        Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(Intent.EXTRA_TEXT, "http://imgur.com/a/" + albumId);
        startActivity(intent);
        return true;
    case R.id.action_new:
        Intent i = new Intent(this.getActivity().getApplicationContext(), ImageSelectActivity.class);
        startActivityForResult(i, 1);
        //select image
        return true;
    case R.id.action_comments:
        if (galleryAlbumData != null) {
            CommentsAsync commentsAsync = new CommentsAsync(((ImgurHoloActivity) getActivity()),
                    galleryAlbumData);
            commentsAsync.execute();
            return true;
        } else
            return super.onOptionsItemSelected(item);
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.kevin.cattalk.ui.SettingsFragment.java

void sendLogThroughMail() {
    String logPath = "";
    try {/*from   ww w. j  a v a2s.  c  om*/
        logPath = EMClient.getInstance().compressLogs();
    } catch (Exception e) {
        e.printStackTrace();
        getActivity().runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getActivity(), "compress logs failed", Toast.LENGTH_LONG).show();
            }
        });
        return;
    }
    File f = new File(logPath);
    File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    if (f.exists() && f.canRead()) {
        try {
            storage.mkdirs();
            File temp = File.createTempFile("hyphenate", ".log.gz", storage);
            if (!temp.canWrite()) {
                return;
            }
            boolean result = f.renameTo(temp);
            if (result == false) {
                return;
            }
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            intent.setData(Uri.parse("mailto:"));
            intent.putExtra(Intent.EXTRA_SUBJECT, "log");
            intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath());

            intent.setType("application/octet-stream");
            ArrayList<Uri> uris = new ArrayList<>();
            uris.add(Uri.fromFile(temp));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            startActivity(intent);
        } catch (final Exception e) {
            e.printStackTrace();
            getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(getContext(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
            });
        }
    }
}

From source file:locationkitapp.locationkit.locationkitapp.MapsActivity.java

private void emailVisitHistory() {
    ArrayList<Uri> uris = new ArrayList<Uri>();
    String filename = String.format(Locale.ENGLISH, "data_%d.csv", System.currentTimeMillis());
    File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    File file = new File(root, filename);
    if (!file.exists()) {
        try {/*from  www . ja  va  2 s  .  c o m*/
            file.createNewFile();
        } catch (IOException e) {
            Log.e(LOG_TAG, "file failed", e);
            return;
        }
    }
    try {
        FileOutputStream os = new FileOutputStream(file);
        os.write(
                "arrival_date,detected_time,visit_id,departure_date,category,subcategory,venue_name,street,city,state,zip,detection_method,latitude,longitude,from_place\n"
                        .getBytes());
        for (Visit v : mVisits) {
            os.write(visitRow(v).getBytes());
        }
        os.close();
    } catch (IOException e) {
        Log.e(LOG_TAG, "ioexception on file", e);
        return;
    }
    uris.add(LKDataManager.EXPORT_DB(this));
    Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("text/plain");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "LocationKitApp ");
    emailIntent.putExtra(Intent.EXTRA_TEXT, "Visits Recorded by LocationKitApp");
    uris.add(Uri.fromFile(file));
    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    startActivity(Intent.createChooser(emailIntent, "Pick an Email provider"));
}

From source file:cn.ucai.wechat.ui.SettingsActivity.java

void sendLogThroughMail() {
    String logPath = "";
    try {/*w w  w .  ja va 2s  . com*/
        logPath = EMClient.getInstance().compressLogs();
    } catch (Exception e) {
        e.printStackTrace();
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(SettingsActivity.this, "compress logs failed", Toast.LENGTH_LONG).show();
            }
        });
        return;
    }
    File f = new File(logPath);
    File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
    if (f.exists() && f.canRead()) {
        try {
            storage.mkdirs();
            File temp = File.createTempFile("hyphenate", ".log.gz", storage);
            if (!temp.canWrite()) {
                return;
            }
            boolean result = f.renameTo(temp);
            if (result == false) {
                return;
            }
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            intent.setData(Uri.parse("mailto:"));
            intent.putExtra(Intent.EXTRA_SUBJECT, "log");
            intent.putExtra(Intent.EXTRA_TEXT, "log in attachment: " + temp.getAbsolutePath());

            intent.setType("application/octet-stream");
            ArrayList<Uri> uris = new ArrayList<>();
            uris.add(Uri.fromFile(temp));
            intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
            startActivity(intent);
        } catch (final Exception e) {
            e.printStackTrace();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(SettingsActivity.this, e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
                }
            });
        }
    }
}