Exemple #1
0
        /// <summary>
        /// Shares the text with image using default Android intent.
        /// </summary>
        /// <param name="subject">Subject.</param>
        /// <param name="body">Body.</param>
        /// <param name="image">Image to send.</param>
        /// <param name="withChooser">If set to <c>true</c> with chooser.</param>
        /// <param name="chooserTitle">Chooser title.</param>
        public static void ShareTextWithImage(string subject, string body, Texture2D image, bool withChooser = true,
                                              string chooserTitle = "Share via...")
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            if (image == null)
            {
                throw new ArgumentNullException("image", "Image must not be null");
            }

            var intent = new AndroidIntent()
                         .SetAction(AndroidIntent.ACTION_SEND)
                         .SetType(AndroidIntent.MIMETypeImage)
                         .PutExtra(AndroidIntent.EXTRA_SUBJECT, subject)
                         .PutExtra(AndroidIntent.EXTRA_TEXT, body);

            var imageUri = AndroidPersistanceUtilsInternal.SaveShareImageToExternalStorage(image);

            intent.PutExtra(AndroidIntent.EXTRA_STREAM, imageUri);

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #2
0
        /// <summary>
        /// Take the screenshot and share using default share intent.
        /// </summary>
        /// <param name="withChooser">If set to <c>true</c> with chooser.</param>
        /// <param name="chooserTitle">Chooser title.</param>
        public static void ShareScreenshot(bool withChooser = true, string chooserTitle = "Share via...")
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            GoodiesSceneHelper.Instance.SaveScreenshotToGallery(uri =>
            {
                var intent = new AndroidIntent()
                             .SetAction(AndroidIntent.ACTION_SEND)
                             .SetType(AndroidIntent.MIMETypeImage);

                intent.PutExtra(AndroidIntent.EXTRA_STREAM, AndroidUri.Parse(uri));

                if (withChooser)
                {
                    AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
                }
                else
                {
                    AGUtils.StartActivity(intent.AJO);
                }
            });
        }
Exemple #3
0
        public static void ShareTextWithImage(string subject, string body, Texture2D image, bool withChooser = true,
                                              string chooserTitle = "Share via...")
        {
            if (AGUtils.IsNotAndroid())
            {
                return;
            }

            if (image == null)
            {
                throw new ArgumentNullException("image", "Image must not be null");
            }

            var intent = new AndroidIntent()
                         .SetAction(AndroidIntent.ActionSend)
                         .SetType(AndroidIntent.MIMETypeImageJpeg)
                         .PutExtra(AndroidIntent.ExtraSubject, subject)
                         .PutExtra(AndroidIntent.ExtraText, body);

            var imageUri = AndroidPersistanceUtilsInternal.SaveImageToCacheDirectory(image);

            intent.PutExtra(AndroidIntent.ExtraStream, imageUri);

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #4
0
        public static void SendMms(string phoneNumber, string message, Texture2D image = null,
                                   bool withChooser    = true,
                                   string chooserTitle = "Send MMS...")
        {
            if (AGUtils.IsNotAndroid())
            {
                return;
            }

            var intent = new AndroidIntent(AndroidIntent.ActionSend);

            intent.PutExtra("address", phoneNumber);
            intent.PutExtra("subject", message);

            if (image != null)
            {
                var imageUri = AndroidPersistanceUtilsInternal.SaveImageToCacheDirectory(image);
                intent.PutExtra(AndroidIntent.ExtraStream, imageUri);
                intent.SetType(AndroidIntent.MIMETypeImagePng);
            }

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #5
0
        public static void SendMms(string phoneNumber, string message, Texture2D image = null,
                                   bool withChooser    = true,
                                   string chooserTitle = "Send MMS...")
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            var intent = new AndroidIntent(AndroidIntent.ACTION_SEND);

            intent.PutExtra("address", phoneNumber);
            intent.PutExtra("sms_body", message);

            if (image != null)
            {
                var imageUri = AndroidPersistanceUtilsInternal.SaveShareImageToExternalStorage(image);
                intent.PutExtra(AndroidIntent.EXTRA_STREAM, imageUri);
                intent.SetType(AndroidIntent.MIMETypeImagePng);
            }

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #6
0
        /// <summary>
        /// Sends the sms using Android intent.
        /// </summary>
        /// <param name="phoneNumber">Phone number.</param>
        /// <param name="message">Message.</param>
        /// <param name="withChooser">If set to <c>true</c> with chooser.</param>
        /// <param name="chooserTitle">Chooser title.</param>
        public static void SendSms(string phoneNumber, string message, bool withChooser = true,
                                   string chooserTitle = "Send SMS...")
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            var intent = CreateSmsIntent(phoneNumber, message);

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #7
0
        /// <summary>
        /// Sends the email using Android intent.
        /// </summary>
        /// <param name="recipients">Recipient email addresses.</param>
        /// <param name="subject">Subject of email.</param>
        /// <param name="body">Body of email.</param>
        /// <param name="attachment">Image to send.</param>
        /// <param name="withChooser">If set to <c>true</c> with chooser.</param>
        /// <param name="chooserTitle">Chooser title.</param>
        /// <param name="cc">Cc recipients. Cc stands for "carbon copy."
        /// Anyone you add to the cc: field of a message receives a copy of that message when you send it.
        /// All other recipients of that message can see that person you designated as a cc
        /// </param>
        /// <param name="bcc">Bcc recipients. Bcc stands for "blind carbon copy."
        /// Anyone you add to the bcc: field of a message receives a copy of that message when you send it.
        /// But, bcc: recipients are invisible to all the other recipients of the message including other bcc: recipients.
        /// </param>
        public static void SendEmail(string[] recipients, string subject, string body,
                                     Texture2D attachment = null, bool withChooser = true, string chooserTitle = "Send mail...",
                                     string[] cc          = null, string[] bcc = null)
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            var intent = CreateEmailIntent(recipients, subject, body, attachment, cc, bcc);

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #8
0
        /// <summary>
        /// Shares the text using default Android intent.
        /// </summary>
        /// <param name="subject">Subject.</param>
        /// <param name="body">Body.</param>
        /// <param name="withChooser">If set to <c>true</c> with chooser.</param>
        /// <param name="chooserTitle">Chooser title.</param>
        public static void ShareText(string subject, string body, bool withChooser = true,
                                     string chooserTitle = "Share via...")
        {
            if (AGUtils.IsNotAndroidCheck())
            {
                return;
            }

            var intent = new AndroidIntent(AndroidIntent.ACTION_SEND)
                         .SetType(AndroidIntent.MIMETypeTextPlain);

            intent.PutExtra(AndroidIntent.EXTRA_SUBJECT, subject);
            intent.PutExtra(AndroidIntent.EXTRA_TEXT, body);

            if (withChooser)
            {
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }
            else
            {
                AGUtils.StartActivity(intent.AJO);
            }
        }
Exemple #9
0
        public static void ShareVideo(string videoPathOnDisc, string title, string chooserTitle = "Share Video")
        {
            if (AGUtils.IsNotAndroid())
            {
                return;
            }

            if (!File.Exists(videoPathOnDisc))
            {
                Debug.LogError("File (video) does not exist to share: " + videoPathOnDisc);
                return;
            }

            AGUtils.RunOnUiThread(() =>
                                  AndroidPersistanceUtilsInternal.ScanFile(videoPathOnDisc, (path, uri) =>
            {
                var intent = new AndroidIntent(AndroidIntent.ActionSend);
                intent.SetType("video/*");
                intent.PutExtra(AndroidIntent.ExtraSubject, title);
                intent.PutExtra(AndroidIntent.ExtraStream, uri);
                AGUtils.StartActivityWithChooser(intent.AJO, chooserTitle);
            }));
        }