ArCoreApk

public class ArCoreApk

Static methods for managing the status of ARCore on the device.

Nested Classes

enum ArCoreApk.Availability Describes the current state of ARCore availability on the device. 
enum ArCoreApk.InstallBehavior Controls the behavior of the installation UI. 
enum ArCoreApk.InstallStatus Indicates the outcome of a call to requestInstall()
enum ArCoreApk.UserMessageType Controls the message displayed by the installation UI. 

Protected Constructors

ArCoreApk()
(FOR TESTING) Constructs a new instance for use as a mock.

Public Methods

ArCoreApk.Availability
checkAvailability(Context applicationContext)
Determines if ARCore is supported on this device.
static ArCoreApk
getInstance()
Returns the singleton instance of ArCoreApk.
ArCoreApk.InstallStatus
requestInstall(Activity applicationActivity, boolean userRequestedInstall)
Initiates installation of ARCore when needed.
ArCoreApk.InstallStatus
requestInstall(Activity applicationActivity, boolean userRequestedInstall, ArCoreApk.InstallBehavior installBehavior, ArCoreApk.UserMessageType messageType)
Initiates installation of ARCore when needed, with configurable behavior.

Inherited Methods

Protected Constructors

protected ArCoreApk ()

(FOR TESTING) Constructs a new instance for use as a mock. Calling any base method implementation on this instance will throw UnsupportedOperationException.

To obtain an ArCoreApk normally, use getInstance().

Public Methods

public ArCoreApk.Availability checkAvailability (Context applicationContext)

Determines if ARCore is supported on this device. This may initiate a query with a remote service to determine if the device is compatible, in which case it will immediately return UNKNOWN_CHECKING.

For ARCore-required apps (as indicated by the manifest meta-data) this method will assume device compatibility and will always immediately return one of SUPPORTED_INSTALLED, SUPPORTED_APK_TOO_OLD, or SUPPORTED_NOT_INSTALLED.

Note: A return value of SUPPORTED_INSTALLED only indicates presence of a suitably versioned ARCore APK. Session creation may still fail if the ARCore APK has been sideloaded onto an incompatible device.

May be called prior to Session(Context).

Parameters
applicationContext Your application's Android context.

public static ArCoreApk getInstance ()

Returns the singleton instance of ArCoreApk.

public ArCoreApk.InstallStatus requestInstall (Activity applicationActivity, boolean userRequestedInstall)

Initiates installation of ARCore when needed. When your apllication launches or enters an AR mode, it should call this method with userRequestedInstall = true.

If ARCore is installed and compatible, this function will return INSTALLED.

If ARCore is not currently installed or the installed version is not compatible, the function will return INSTALL_REQUESTED immediately. Your current activity will then pause while the user is offered the opportunity to install it.

When your activity resumes, you should call this method again, this time with userRequestedInstall = false. This will either return INSTALLED or throw an exception indicating the reason that installation could not be completed.

ARCore-optional applications must ensure that checkAvailability(Context) returns one of the SUPPORTED_... values before calling this method.

See our sample code for an example of how an ARCore-required application should use this function.

May be called prior to Session(Context).

For more control over the message displayed and ease of exiting the process, see requestInstall(Activity, boolean, InstallBehavior, UserMessageType).

Parameters
applicationActivity Your application's current activity. Used for launching an intent to display the installation user interface.
userRequestedInstall if set, override the previous installation failure message and always show the installation interface.
Throws
FatalException if an error occurs while checking compatibility or starting installation
UnavailableDeviceNotCompatibleException if ARCore is not supported on this device.
UnavailableUserDeclinedInstallationException if the user previously declined installation and userRequestedInstall is false.

public ArCoreApk.InstallStatus requestInstall (Activity applicationActivity, boolean userRequestedInstall, ArCoreApk.InstallBehavior installBehavior, ArCoreApk.UserMessageType messageType)

Initiates installation of ARCore when needed, with configurable behavior.

This is a more flexible version of requestInstall(Activity, boolean) allowing the application control over the initial informational dialog and ease of exiting or cancelling the installation.

See requestInstall(Activity, boolean) for details of use and behavior.

Parameters
applicationActivity Your application's current activity. Used for launching an intent to display the installation user interface.
userRequestedInstall if set, override the previous installation failure message and always show the installation interface.
installBehavior controls the presence of the cancel button at the user education screen and if tapping outside the education screen or install-in-progress screen causes them to dismiss.
messageType controls the text of the of message displayed before showing the install prompt, or disables display of this message.
Throws
FatalException if an error occurs while checking compatibility or starting installation
UnavailableDeviceNotCompatibleException if ARCore is not supported on this device.
UnavailableUserDeclinedInstallationException if the user previously declined installation and userRequestedInstall is false.

Send feedback about...