Skip to content

5. Other useful methods

Taras Leskiv edited this page Jul 8, 2016 · 11 revisions

Android Goodies also contains other methods that might be useful for Android.

Checking if the app with certain package is installed

Knowing the app package you can check whether the app is installed on the device using method AndroidUtils.IsPackageInstalled(string package).

You can find the app package on Google Play like this:

Check Application Package.

There are also helper methods to check if official Twitter app is installed, if user has any email app client and if user has any SMS app or maps client.

  • AndroidShare.IsTwitterInstalled()
  • AndroidShare.UserHasEmailApp()
  • AndroidShare.UserHasSmsApp()
  • AndroidMaps.UserHasMapsApp()

Showing Toast

You can show toast (short or long) like this:

AndroidGoodiesMisc.ShowToast("hello long!", AndroidGoodiesMisc.ToastLength.Long);

To enable immersive mode invoke:

AndroidGoodiesMisc.EnableImmersiveMode();

Note that Unity 5 has immersive mode enabled by default, so if your using Unity 5 or higher, this method is redundant.

Other Device info

From android.provider.Settings.Secure:

  • ANDROID_ID - A 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device. The value may change if a factory reset is performed on the device.

You can retrieve the following properties from android.os.Build class:

  • DEVICE - The name of the industrial design.
  • MODEL - The end-user-visible name for the end product.
  • PRODUCT - The name of the overall product.
  • MANUFACTURER - The manufacturer of the product/hardware.

You can retrieve the following properties from android.os.Build.VERSION class:

  • BASE_OS - The base OS build the product is based on.
  • CODENAME - The current development codename, or the string "REL" if this is a release build.
  • INCREMENTAL - The internal value used by the underlying source control to represent this build.
  • PREVIEW_SDK_INT - The developer preview revision of a prerelease SDK.
  • RELEASE - The user-visible version string.
  • SDK_INT - The user-visible SDK version of the framework; its possible values are defined in Build.VERSION_CODES.
  • SECURITY_PATCH - The user-visible security patch level.
Clone this wiki locally