/// <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); } }); }
/// <summary> /// Show the map at the given longitude and latitude at a certain zoom level. /// A zoom level of 1 shows the whole Earth, centered at the given lat,lng. The highest (closest) zoom level is 23. /// </summary> /// <param name="latitude">The latitude of the location. May range from -90.0 to 90.0.</param> /// <param name="longitude">The longitude of the location. May range from -180.0 to 180.0.</param> /// <param name="zoom">Zoom level.</param> public static void OpenMapLocation(float latitude, float longitude, int zoom = DefaultMapZoomLevel) { if (AGUtils.IsNotAndroidCheck()) { return; } if (latitude < -90.0f || latitude > 90.0f) { throw new ArgumentOutOfRangeException("latitude", "Latitude must be from -90.0 to 90.0."); } if (longitude < -180.0f || longitude > 180.0f) { throw new ArgumentOutOfRangeException("longitude", "Longitude must be from -180.0 to 180.0."); } if (zoom < MinMapZoomLevel || zoom > MaxMapZoomLevel) { throw new ArgumentOutOfRangeException("zoom", "Zoom level must be between 1 and 23"); } var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW); var uri = AndroidUri.Parse(string.Format(MapUriFormat, latitude, longitude, zoom)); intent.SetData(uri); AGUtils.StartActivity(intent.AJO); }
private static AndroidIntent CreateEmailIntent(string[] recipients, string subject, string body, Texture2D attachment = null, string[] cc = null, string[] bcc = null) { var uri = AndroidUri.Parse("mailto:"); var intent = new AndroidIntent() .SetAction(AndroidIntent.ACTION_SENDTO) .SetData(uri) .PutExtra(AndroidIntent.EXTRA_EMAIL, recipients) .PutExtra(AndroidIntent.EXTRA_SUBJECT, subject) .PutExtra(AndroidIntent.EXTRA_TEXT, body); if (cc != null) { intent.PutExtra(AndroidIntent.EXTRA_CC, cc); } if (bcc != null) { intent.PutExtra(AndroidIntent.EXTRA_BCC, bcc); } if (attachment != null) { var imageUri = AndroidPersistanceUtilsInternal.SaveShareImageToExternalStorage(attachment); intent.PutExtra(AndroidIntent.EXTRA_STREAM, imageUri); } return(intent); }
/// <summary> /// Show the map at the given longitude and latitude with a certain label. /// </summary> /// <param name="latitude">The latitude of the location. May range from -90.0 to 90.0.</param> /// <param name="longitude">The longitude of the location. May range from -180.0 to 180.0.</param> /// <param name="label">Label to mark the point.</param> public static void OpenMapLocationWithLabel(float latitude, float longitude, string label) { if (AGUtils.IsNotAndroidCheck()) { return; } if (latitude < -90.0f || latitude > 90.0f) { throw new ArgumentOutOfRangeException("latitude", "Latitude must be from -90.0 to 90.0."); } if (longitude < -180.0f || longitude > 180.0f) { throw new ArgumentOutOfRangeException("longitude", "Longitude must be from -180.0 to 180.0."); } if (string.IsNullOrEmpty(label)) { throw new ArgumentException("Label must not be null or empty"); } var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW); var uri = AndroidUri.Parse(string.Format(MapUriFormatLabel, latitude, longitude, label)); intent.SetData(uri); AGUtils.StartActivity(intent.AJO); }
static AndroidIntent CreateEmailIntent(string[] recipients, string subject, string body, Texture2D attachment = null, string[] cc = null, string[] bcc = null) { var uri = AndroidUri.Parse("mailto:"); var intent = new AndroidIntent() .SetAction(AndroidIntent.ActionSendTo) .SetData(uri) .PutExtra(AndroidIntent.ExtraEmail, recipients) .PutExtra(AndroidIntent.ExtraSubject, subject) .PutExtra(AndroidIntent.ExtraText, body); if (cc != null) { intent.PutExtra(AndroidIntent.ExtraCc, cc); } if (bcc != null) { intent.PutExtra(AndroidIntent.ExtraBcc, bcc); } if (attachment != null) { var imageUri = AndroidPersistanceUtilsInternal.SaveImageToCacheDirectory(attachment); intent.PutExtra(AndroidIntent.ExtraStream, imageUri); } return(intent); }
/// <summary> /// Checks if user has any maps apps installed. /// </summary> /// <returns><c>true</c>, if user has any maps apps installed., <c>false</c> otherwise.</returns> public static bool UserHasMapsApp() { if (AGUtils.IsNotAndroidCheck()) { return(false); } // Dummy intent just to check if any apps can handle the intent var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW); var uri = AndroidUri.Parse(string.Format(MapUriFormat, 0, 0, DefaultMapZoomLevel)); return(intent.SetData(uri).ResolveActivity()); }
public void SetSound([NotNull] string soundFilePath, AudioAttributes audioAttributes) { if (soundFilePath == null) { throw new ArgumentNullException("soundFilePath"); } if (ApiCheck) { return; } AJO.Call("setSound", AndroidUri.FromFile(soundFilePath), audioAttributes == null ? null : audioAttributes.AJO); }
/// <summary> /// Watch YouTube video. Opens video in YouTube app if its installed, falls back to browser. /// </summary> /// <param name="id">YouTube video id</param> public static void WatchYoutubeVideo(string id) { if (AGUtils.IsNotAndroidCheck()) { return; } var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW, AndroidUri.Parse("vnd.youtube:" + id)); AGUtils.StartActivity(intent.AJO, () => { var fallbackIntent = new AndroidIntent(AndroidIntent.ACTION_VIEW, AndroidUri.Parse("http://www.youtube.com/watch?v=" + id)); AGUtils.StartActivity(fallbackIntent.AJO); }); }
private static AndroidIntent CreateSmsIntent(string phoneNumber, string message) { var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW); if (AGDeviceInfo.SDK_INT >= AGDeviceInfo.VersionCodes.KITKAT) { var uri = AndroidUri.Parse(string.Format(SmsUriFormat, phoneNumber)); intent.SetData(uri); } else { intent.SetType("vnd.android-dir/mms-sms"); intent.PutExtra("address", phoneNumber); } intent.PutExtra("sms_body", message); return(intent); }
/// <summary> /// DIsplays the prompt to uninstall the app. /// </summary> /// <param name="package">Package to uninstall.</param> public static void UninstallApp(string package) { if (AGUtils.IsNotAndroidCheck()) { return; } try { var uri = AndroidUri.Parse(string.Format("package:{0}", package)); var intent = new AndroidIntent(AndroidIntent.ACTION_DELETE, uri); AGUtils.StartActivity(intent.AJO); } catch { // ignore } }
/// <summary> /// Open application details settings /// </summary> /// <param name="package">Package of the application to open settings</param> public static void OpenApplicationDetailsSettings(string package) { if (AGUtils.IsNotAndroidCheck()) { return; } var intent = new AndroidIntent(ACTION_APPLICATION_DETAILS_SETTINGS); intent.SetData(AndroidUri.Parse(string.Format("package:{0}", package))); if (intent.ResolveActivity()) { AGUtils.StartActivity(intent.AJO); } else { Debug.LogWarning("Could not open application details settings for package " + package + ". Most likely application is not installed."); } }
/// <summary> /// Installs the apk file from SD card. The file MUST exist. Always check if file exists before invoking the method. /// </summary> /// <param name="apkPathOnDisc">APK path on disc.</param> public static void InstallApkFileFromSDCard(string apkPathOnDisc) { if (AGUtils.IsNotAndroidCheck()) { return; } try { var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW); intent.SetDataAndType(AndroidUri.FromFile(apkPathOnDisc), "application/vnd.android.package-archive"); AGUtils.StartActivity(intent.AJO); } catch { if (Debug.isDebugBuild) { Debug.Log("Could not find apk file:" + apkPathOnDisc); } } }
/// <summary> /// Opens the map location with the provided address. /// </summary> /// <param name="address">Address to open.</param> public static void OpenMapLocation(string address) { if (AGUtils.IsNotAndroidCheck()) { return; } if (string.IsNullOrEmpty(address)) { throw new ArgumentException("Address must not be null or empty"); } // Note: All strings passed in the geo URI must be encoded. For example, the string 1st & Pike, Seattle should become 1st%20%26%20Pike%2C%20Seattle. // Spaces in the string can be encoded with %20 or replaced with the plus sign (+). address = WWW.EscapeURL(address); var intent = new AndroidIntent(AndroidIntent.ACTION_VIEW); var uri = AndroidUri.Parse(string.Format(MapUriFormatAddress, address)); intent.SetData(uri); AGUtils.StartActivity(intent.AJO); }
static AndroidJavaObject ParsePhoneNumber(string phoneNumber) { return(AndroidUri.Parse("tel:" + phoneNumber)); }
static AndroidIntent GetViewProfileIntent(string uriFormat, string profileId) { var url = string.Format(uriFormat, profileId); return(new AndroidIntent(AndroidIntent.ACTION_VIEW, AndroidUri.Parse(url))); }