Example usage for android.content Intent setDataAndType

List of usage examples for android.content Intent setDataAndType

Introduction

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

Prototype

public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) 

Source Link

Document

(Usually optional) Set the data for the intent along with an explicit MIME data type.

Usage

From source file:com.linroid.pushapp.service.DownloadService.java

private void showNotification(Pack pack, int progress) {
    if (pack == null) {
        return;// w w  w  .j  a  va2s.  c  o  m
    }
    if (prevProgress == progress) {
        return;
    }
    prevProgress = progress;
    String contentText;
    if (progress == 100) {
        contentText = getString(R.string.msg_download_complete);
    } else if (progress < 0) {
        contentText = getString(R.string.msg_download_failed);
        Toast.makeText(this, getString(R.string.toast_download_failed, pack.getAppName()), Toast.LENGTH_SHORT)
                .show();
    } else {
        if (progress == 0) {
            Toast.makeText(this, getString(R.string.toast_start_download, pack.getAppName()), Toast.LENGTH_LONG)
                    .show();
        }
        contentText = getString(R.string.msg_downloading);
    }
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
            .setContentTitle(
                    getString(R.string.msg_download_title, pack.getAppName(), "v" + pack.getVersionName()))
            .setSmallIcon(R.mipmap.ic_launcher).setAutoCancel(false).setContentText(contentText);
    if (progress > 0) {
        builder.setProgress(100, Math.max(progress, 0), false)
                .setContentInfo(getString(R.string.msg_download_progress, progress));
    } else if (progress == 0) {
        builder.setProgress(100, 0, true);
    }
    if (progress == 100) {
        builder.setSmallIcon(R.drawable.ic_stat_complete);
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(pack.getPath())),
                "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        PendingIntent pi = PendingIntent.getActivity(this, 0x1, intent, 0);
        builder.setContentIntent(pi);
    }
    //        ImageRequest request = ImageRequest.fromUri(pack.getIconUrl());
    //        ImagePipeline pipeline = Fresco.getImagePipeline();
    //        pipeline.prefetchToDiskCache(request, this);
    notificationManager.notify(pack.getId(), builder.build());
}

From source file:com.example.shinelon.ocrcamera.MainActivity.java

public void crop(Uri uri) {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, "image/*");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    startActivityForResult(intent, CROP);
    setImage(uri);/*w w w .  j  a  v a  2 s .c om*/
    mCropButton.setEnabled(true);
}

From source file:com.digitalarx.android.files.FileOperationsHelper.java

public void openFile(OCFile file) {
    if (file != null) {
        String storagePath = file.getStoragePath();
        String encodedStoragePath = WebdavUtils.encodePath(storagePath);

        Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
        intentForSavedMimeType.setDataAndType(Uri.parse("file://" + encodedStoragePath), file.getMimetype());
        intentForSavedMimeType//from   w w  w . java2  s . c  o m
                .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

        Intent intentForGuessedMimeType = null;
        if (storagePath.lastIndexOf('.') >= 0) {
            String guessedMimeType = MimeTypeMap.getSingleton()
                    .getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1));
            if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
                intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
                intentForGuessedMimeType.setDataAndType(Uri.parse("file://" + encodedStoragePath),
                        guessedMimeType);
                intentForGuessedMimeType.setFlags(
                        Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            }
        }

        Intent chooserIntent = null;
        if (intentForGuessedMimeType != null) {
            chooserIntent = Intent.createChooser(intentForGuessedMimeType,
                    mFileActivity.getString(R.string.actionbar_open_with));
        } else {
            chooserIntent = Intent.createChooser(intentForSavedMimeType,
                    mFileActivity.getString(R.string.actionbar_open_with));
        }

        mFileActivity.startActivity(chooserIntent);

    } else {
        Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
    }
}

From source file:com.activiti.android.app.fragments.content.ContentsFragment.java

@Subscribe
public void onDownloadTransferEvent(DownloadTransferEvent event) {
    if (event.hasException) {
        Snackbar.make(getActivity().findViewById(R.id.left_panel), event.exception.getMessage(),
                Snackbar.LENGTH_SHORT).show();
        return;//from w  w  w .  j a  va  2 s.  c  om
    }

    if (waitingDialog != null) {
        waitingDialog.dismiss();
    }

    try {
        switch (event.mode) {
        case ContentTransferSyncAdapter.MODE_SHARE:
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName());
            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(event.data));
            sendIntent.setType(event.mimetype);
            getActivity().startActivity(
                    Intent.createChooser(sendIntent, getResources().getText(R.string.action_send_file)));
            break;
        case ContentTransferSyncAdapter.MODE_OPEN_IN:
            Intent viewIntent = new Intent(Intent.ACTION_VIEW);
            viewIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName());
            viewIntent.setDataAndType(Uri.fromFile(event.data), event.mimetype);
            startActivity(viewIntent);
            break;
        }
    } catch (ActivityNotFoundException e) {
        Snackbar.make(getActivity().findViewById(R.id.left_panel), R.string.file_editor_error_open,
                Snackbar.LENGTH_SHORT).show();
    }
}

From source file:com.bordengrammar.bordengrammarapp.ParentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.fragment_parents, container, false);
    mail = (LinearLayout) root.findViewById(R.id.linmail);
    call = (LinearLayout) root.findViewById(R.id.lincall);
    call.setOnClickListener(new View.OnClickListener() {
        @Override/*from ww  w. ja  v  a  2 s. c  om*/
        public void onClick(View arg0) {
            Intent cally = new Intent(Intent.ACTION_CALL);
            cally.setData(Uri.parse("tel:01795424192"));
            startActivity(cally);
        }
    });
    mail.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
            alert.setTitle("Send a email to Borden Grammar");
            alert.setMessage("Message: ");
            final EditText input = new EditText(getActivity());
            alert.setView(input);
            alert.setPositiveButton("Send", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = input.getText().toString();
                    // Do something with value!
                    Intent email = new Intent(Intent.ACTION_SEND);
                    email.setType("plain/text");
                    email.putExtra(android.content.Intent.EXTRA_EMAIL,
                            new String[] { "school@bordengrammar.kent.sch.uk" });
                    email.putExtra(Intent.EXTRA_SUBJECT, "Email (Sent From BGS APP) ");
                    email.putExtra(Intent.EXTRA_TEXT, value);
                    startActivity(Intent.createChooser(email, "Choose an Email client :"));
                }
            });
            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Canceled.
                }
            });
            alert.show();
        }

    });

    URL url = null;
    try {
        url = new URL(
                "http://website.bordengrammar.kent.sch.uk/index.php?option=com_rubberdoc&view=category&id=63%3Aletters&Itemid=241&format=feed&type=rss");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    Feed feed = null;
    try {
        feed = FeedParser.parse(url);
    } catch (FeedIOException e) {
        e.printStackTrace();
    } catch (FeedXMLParseException e) {
        e.printStackTrace();
    } catch (UnsupportedFeedException e) {
        e.printStackTrace();
    }
    Boolean nully = false;
    for (int i = 0; i < 3; i++) {
        try {
            FeedItem item = feed.getItem(i);
        } catch (NullPointerException e) {
            e.printStackTrace();
            nully = true;
            Toast.makeText(getActivity().getApplicationContext(),
                    "Some features of this app require a internet connection", Toast.LENGTH_LONG).show();
        }
    }
    if (!nully) {
        final FeedItem post1 = feed.getItem(1);
        final FeedItem post2 = feed.getItem(2);
        final FeedItem post3 = feed.getItem(3);
        TextView title1 = (TextView) root.findViewById(R.id.title1);
        TextView title2 = (TextView) root.findViewById(R.id.title2);
        TextView title3 = (TextView) root.findViewById(R.id.title3);
        title1.setText(post1.getTitle());
        title2.setText(post2.getTitle());
        title3.setText(post3.getTitle());
        TextView link1 = (TextView) root.findViewById(R.id.link1);
        TextView link2 = (TextView) root.findViewById(R.id.link2);
        TextView link3 = (TextView) root.findViewById(R.id.link3);
        link1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url1 = post1.getLink().toString();
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse(url1), "text/html");
                startActivity(intent);
            }
        });
        link2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url1 = post2.getLink().toString();
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse(url1), "text/html");
                startActivity(intent);
            }
        });
        link3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url1 = post3.getLink().toString();
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.parse(url1), "text/html");
                startActivity(intent);
            }
        });

    } else {
        TextView title1 = (TextView) root.findViewById(R.id.title1);
        TextView title2 = (TextView) root.findViewById(R.id.title2);
        TextView title3 = (TextView) root.findViewById(R.id.title3);
        title1.setText("No connection");
        title2.setText("No connection");
        title3.setText("No connection");
    }
    TextView reader = (TextView) root.findViewById(R.id.reader);
    reader.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String appPackageName = "com.adobe.reader"; // getPackageName() from Context or Activity object
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
            }
        }
    });

    return root;
}

From source file:com.media.LuYinFragment.java

private void setAdapter(Cursor imagecursor) {
    if (imagecursor.getCount() > 0) {

        mGalleryModelList = new ArrayList<MediaModel>();

        for (int i = 0; i < imagecursor.getCount(); i++) {
            imagecursor.moveToPosition(i);
            int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Audio.Media.DATA);
            MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false);
            mGalleryModelList.add(galleryModel);
        }//w ww .  j  a  va  2  s.co m

        mImageAdapter = new AudioListViewAdapter(getActivity(), 0, mGalleryModelList, false);
        audioListView.setAdapter(mImageAdapter);
    } else {
        Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available),
                Toast.LENGTH_SHORT).show();
    }

    audioListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            AudioListViewAdapter adapter = (AudioListViewAdapter) parent.getAdapter();
            MediaModel galleryModel = (MediaModel) adapter.getItem(position);
            File file = new File(galleryModel.url);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(file), "audio/*");
            startActivity(intent);
            return true;
        }
    });

    audioListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // update the mStatus of each category in the adapter
            AudioListViewAdapter adapter = (AudioListViewAdapter) parent.getAdapter();
            MediaModel galleryModel = (MediaModel) adapter.getItem(position);

            if (!galleryModel.status) {
                long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()),
                        false);
                if (size != 0) {
                    Toast.makeText(getActivity(),
                            getActivity().getResources().getString(R.string.file_size_exeeded) + "  "
                                    + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " "
                                    + getActivity().getResources().getString(R.string.mb),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) {
                    if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) {
                        Toast.makeText(getActivity(),
                                getActivity().getResources().getString(R.string.max_limit_file) + "  "
                                        + MediaChooserConstants.SELECTED_MEDIA_COUNT + " "
                                        + getActivity().getResources().getString(R.string.file),
                                Toast.LENGTH_SHORT).show();
                        return;
                    } else {
                        Toast.makeText(getActivity(),
                                getActivity().getResources().getString(R.string.max_limit_file) + "  "
                                        + MediaChooserConstants.SELECTED_MEDIA_COUNT + " "
                                        + getActivity().getResources().getString(R.string.files),
                                Toast.LENGTH_SHORT).show();
                        return;
                    }

                }
            }

            // inverse the status
            galleryModel.status = !galleryModel.status;

            adapter.notifyDataSetChanged();

            if (galleryModel.status) {
                mSelectedItems.add(galleryModel.url.toString());
                MediaChooserConstants.SELECTED_MEDIA_COUNT++;

            } else {
                mSelectedItems.remove(galleryModel.url.toString().trim());
                MediaChooserConstants.SELECTED_MEDIA_COUNT--;
            }

            if (mCallback != null) {
                mCallback.onLuYinSelected(mSelectedItems.size());
                Intent intent = new Intent();
                intent.putStringArrayListExtra("list", mSelectedItems);
                getActivity().setResult(Activity.RESULT_OK, intent);
            }

        }
    });
}

From source file:com.compassites.texteditor.RichTextEditorDemoActivity.java

private void showFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath());
    intent.setDataAndType(uri, "text/*");
    startActivityForResult(Intent.createChooser(intent, "Open folder"), FILE_SELECT_CODE);
}

From source file:com.jaspersoft.android.jaspermobile.activities.storage.fragment.SavedItemsFragment.java

private void openReportFile(File reportOutputFile, String recordUri) {
    Locale current = getResources().getConfiguration().locale;
    String fileName = reportOutputFile.getName();
    String baseName = FileUtils.getBaseName(fileName);
    String extension = FileUtils.getExtension(fileName).toLowerCase(current);

    if ("HTML".equalsIgnoreCase(extension)) {
        // run the html report viewer
        SavedReportHtmlViewerActivity_.intent(this).reportFile(reportOutputFile).resourceLabel(baseName)
                .recordUri(recordUri).start();
    } else {/*ww w.j a v a 2 s. c o  m*/
        // run external viewer according to the file format
        String contentType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
        Uri reportOutputPath = Uri.fromFile(reportOutputFile);
        Intent externalViewer = new Intent(Intent.ACTION_VIEW);
        externalViewer.setDataAndType(reportOutputPath, contentType);
        externalViewer.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        try {
            startActivity(externalViewer);
        } catch (ActivityNotFoundException e) {
            // show notification if no app available to open selected format
            Toast.makeText(getActivity(), getString(R.string.sdr_t_no_app_available, extension),
                    Toast.LENGTH_SHORT).show();
        }
    }
}

From source file:com.dazone.crewchat.libGallery.fragment.ImageFragment.java

private void setAdapter(Cursor imagecursor) {

    if (imagecursor.getCount() > 0) {

        mGalleryModelList = new ArrayList<MediaModel>();

        for (int i = 0; i < imagecursor.getCount(); i++) {
            imagecursor.moveToPosition(i);
            int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA);
            MediaModel galleryModel = new MediaModel(imagecursor.getString(dataColumnIndex).toString(), false);
            mGalleryModelList.add(galleryModel);
        }// w w  w. j  a va 2  s .com

        mImageAdapter = new GridViewAdapter(getActivity(), 0, mGalleryModelList, false);
        mImageGridView.setAdapter(mImageAdapter);
    } else {
        Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available),
                Toast.LENGTH_SHORT).show();
    }

    mImageGridView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter();
            MediaModel galleryModel = (MediaModel) adapter.getItem(position);
            File file = new File(galleryModel.url);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(file), "image/*");
            startActivity(intent);
            return true;
        }
    });

    mImageGridView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // update the mStatus of each category in the adapter
            GridViewAdapter adapter = (GridViewAdapter) parent.getAdapter();
            MediaModel galleryModel = (MediaModel) adapter.getItem(position);

            if (!galleryModel.status) {
                long size = MediaChooserConstants.ChekcMediaFileSize(new File(galleryModel.url.toString()),
                        false);
                if (size != 0) {
                    Toast.makeText(getActivity(),
                            getActivity().getResources().getString(R.string.file_size_exeeded) + "  "
                                    + MediaChooserConstants.SELECTED_IMAGE_SIZE_IN_MB + " "
                                    + getActivity().getResources().getString(R.string.mb),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                if ((MediaChooserConstants.MAX_MEDIA_LIMIT == MediaChooserConstants.SELECTED_MEDIA_COUNT)) {
                    if (MediaChooserConstants.SELECTED_MEDIA_COUNT < 2) {
                        Toast.makeText(getActivity(),
                                getActivity().getResources().getString(R.string.max_limit_file) + "  "
                                        + MediaChooserConstants.SELECTED_MEDIA_COUNT + " "
                                        + getActivity().getResources().getString(R.string.file),
                                Toast.LENGTH_SHORT).show();
                        return;
                    } else {
                        Toast.makeText(getActivity(),
                                getActivity().getResources().getString(R.string.max_limit_file) + "  "
                                        + MediaChooserConstants.SELECTED_MEDIA_COUNT + " "
                                        + getActivity().getResources().getString(R.string.files),
                                Toast.LENGTH_SHORT).show();
                        return;
                    }

                }
            }

            // inverse the status
            galleryModel.status = !galleryModel.status;

            adapter.notifyDataSetChanged();

            if (galleryModel.status) {
                mSelectedItems.add(galleryModel.url.toString());
                MediaChooserConstants.SELECTED_MEDIA_COUNT++;

            } else {
                mSelectedItems.remove(galleryModel.url.toString().trim());
                MediaChooserConstants.SELECTED_MEDIA_COUNT--;
            }

            if (mCallback != null) {
                mCallback.onImageSelected(mSelectedItems.size());
                Intent intent = new Intent();
                intent.putStringArrayListExtra("list", mSelectedItems);
                getActivity().setResult(Activity.RESULT_OK, intent);
            }

        }
    });
}

From source file:com.dynamixsoftware.printingsample.ShareIntentFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.share_image_action_view: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        Log.i("testtest", Uri.parse("file://" + imageFilePath).toString());

        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + imageFilePath), "image/png");
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else//  ww  w  .j a  va  2s.  c o  m
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_image_action_send: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("image/png");
            intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + imageFilePath));
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_image_multiple: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
            Uri uri = Uri.parse("file://" + imageFilePath);
            ArrayList<Uri> urisList = new ArrayList<>();
            urisList.add(uri);
            urisList.add(uri);
            urisList.add(uri);
            intent.putExtra(Intent.EXTRA_STREAM, urisList);
            intent.setType("image/*");
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else {
            showOpenFileErrorDialog();
        }
        break;
    }
    case R.id.share_image_return: {
        String imageFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_PNG);
        if (imageFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_VIEW); // can be ACTION_SEND - see share_image_action_send for properly configure intent
            intent.setDataAndType(Uri.parse("file://" + imageFilePath), "image/png");
            if (startPrintHandActivityForResultFailed(intent, REQUEST_CODE_IMAGE))
                showStartPrintHandActivityErrorDialog();
        } else
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_file: {
        String docFilePath = FilesUtils.getFilePath(requireContext(), FilesUtils.FILE_DOC);
        if (docFilePath != null) {
            Intent intent = new Intent(Intent.ACTION_VIEW); // can be ACTION_SEND - see share_image_action_send for properly configure intent
            intent.setDataAndType(Uri.parse("file://" + docFilePath), "application/msword"); // scheme "content://" also available
            // MIME types available:
            // application/pdf
            // application/vnd.ms-word
            // application/ms-word
            // application/msword
            // application/vnd.openxmlformats-officedocument.wordprocessingml.document
            // application/vnd.ms-excel
            // application/ms-excel
            // application/msexcel
            // application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
            // application/vnd.ms-powerpoint
            // application/ms-powerpoint
            // application/mspowerpoint
            // application/vnd.openxmlformats-officedocument.presentationml.presentation
            // application/haansofthwp
            // text/plain
            // text/html
            if (startPrintHandActivityFailed(intent))
                showStartPrintHandActivityErrorDialog();
        } else
            showOpenFileErrorDialog();
        break;
    }
    case R.id.share_web_page_uri: {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse("http://printhand.com"), "text/html"); // worked only 'http' - bug in PrintHand?
        if (startPrintHandActivityFailed(intent))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    case R.id.share_web_page_string: {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/html");
        intent.putExtra(Intent.EXTRA_TEXT, "https://printhand.com");
        if (startPrintHandActivityFailed(intent))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    case R.id.activate_license: {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, "YOUR_KEY_HERE"); // put your activation key here
        intent.setType("text/license");
        intent.putExtra("showErrorMessage", true); // if true PrintHand shown error message
        intent.putExtra("return", false); // if true (and showErrorMessage is false) PrintHand provide result to your onActivityResult
        if (startPrintHandActivityFailed(intent))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    case R.id.activate_license_return: {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_TEXT, "YOUR_KEY_HERE"); // put your activation key here
        intent.setType("text/license");
        intent.putExtra("showErrorMessage", false); // if true PrintHand shown error message
        intent.putExtra("return", true); // if true (and showErrorMessage is false) PrintHand provide result to your onActivityResult
        if (startPrintHandActivityForResultFailed(intent, REQUEST_CODE_LICENSE))
            showStartPrintHandActivityErrorDialog();
        break;
    }
    }
}