Skip to content

Share Intent

Roman Tcaregorodtcev edited this page Mar 22, 2018 · 1 revision

Activity Action: Deliver some data to someone else. Who the data is being delivered to is not specified; it is up to the receiver of this action to ask the user where the data should be sent.

When launching a SEND intent, you should usually wrap it in a chooser (through createChooser(Intent, CharSequence)), which will give the proper interface for the user to pick how to send your data and allow you to specify a prompt indicating what they are doing.

OmegaIntentBuilder.from(context)
                    .share()
                    .emailTo("develop@omega-r.com")
                    .emailBcc("bcc1@test.com","bcc2@test.com") // Concealed addresses
                    .emailCc("cc1@test.com","cc2@test.com")  // Copy addresses
                    .subject("Great library")
                    .createIntentHandler()
                    .chooserTitle("Choose")
                    .startActivity();

You can download file from internet and put it to intent.

OmegaIntentBuilder.from(context)
                    .share()
                    .emailTo("your_email_here@gmail.com")
                    .subject("Great library")
                    .filesUrls("https://developer.android.com/studio/images/hero_image_studio.png")
                    .fileUrlWithMimeType("https://avatars1.githubusercontent.com/u/28600571?s=200&v=4", MimeTypes.IMAGE_PNG)
                    .download(new DownloadCallback() {
                        @Override
                        public void onDownloaded(boolean success, @NotNull ContextIntentHandler contextIntentHandler) {
                            contextIntentHandler.startActivity();
                        }
                    });