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. |
Public Methods
ArCoreApk.Availability
|
checkAvailability(Context applicationContext)
Determines if ARCore is supported on this device.
|
void
|
checkAvailabilityAsync(Context applicationContext, Consumer<ArCoreApk.Availability> callback)
Asynchronously 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
Public Methods
public ArCoreApk.Availability checkAvailability (Context applicationContext)
checkAvailability
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
ArCoreApk.Availability.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 ArCoreApk.Availability.SUPPORTED_INSTALLED
, ArCoreApk.Availability.SUPPORTED_APK_TOO_OLD
, or
ArCoreApk.Availability.SUPPORTED_NOT_INSTALLED
.
Note: A return value of ArCoreApk.Availability.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.Session(Context)
.
Details | |||
---|---|---|---|
Parameters |
|
public void checkAvailabilityAsync (Context applicationContext, Consumer<ArCoreApk.Availability> callback)
checkAvailabilityAsync
public void checkAvailabilityAsync( Context applicationContext, Consumer<ArCoreApk.Availability> callback )
Asynchronously determines if ARCore is supported on this device. This may initiate a query with a remote service to determine if the device is compatible.
The callback will be invoked asynchronously on the Main thread. Unlike the synchronous
method checkAvailability(Context)
, the result will never be ArCoreApk.Availability.UNKNOWN_CHECKING
.
For ARCore-required apps (as indicated by the manifest
meta-data) this method will assume device compatibility and the callback will be
asynchronously invoked on the Main thread with one of ArCoreApk.Availability.SUPPORTED_INSTALLED
,
ArCoreApk.Availability.SUPPORTED_APK_TOO_OLD
, or ArCoreApk.Availability.SUPPORTED_NOT_INSTALLED
.
Note: A result value of ArCoreApk.Availability.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.Session(Context)
.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
public static ArCoreApk getInstance ()
getInstance
public static ArCoreApk getInstance()
Returns the singleton instance of ArCoreApk.
public ArCoreApk.InstallStatus requestInstall (Activity applicationActivity, boolean userRequestedInstall)
requestInstall
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 ArCoreApk.InstallStatus.INSTALLED
.
If ARCore is not currently installed or the installed version is not compatible, the
function will return ArCoreApk.InstallStatus.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 ArCoreApk.InstallStatus.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.Session(Context)
.
For more control over the message displayed and ease of exiting the process, see requestInstall(Activity, boolean, InstallBehavior, UserMessageType)
.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Throws |
|
public ArCoreApk.InstallStatus requestInstall (Activity applicationActivity, boolean userRequestedInstall, ArCoreApk.InstallBehavior installBehavior, ArCoreApk.UserMessageType messageType)
requestInstall
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.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Throws |
|