BaseArFragment

public abstract class BaseArFragment
Known Direct Subclasses

The AR fragment brings in the required view layout and controllers for common AR features.

Nested Classes

interface BaseArFragment.OnTapArPlaneListener Invoked when an ARCore plane is tapped. 

Public Constructors

Public Methods

abstract String[]
getAdditionalPermissions()
Returns an array of dangerous permissions that are required by the app in addition to Manifest.permission.CAMERA, which is needed by ARCore.
ArSceneView
getArSceneView()
Gets the ArSceneView for this fragment.
PlaneDiscoveryController
getPlaneDiscoveryController()
Gets the plane discovery controller, which displays instructions for how to scan for planes.
TransformationSystem
getTransformationSystem()
Gets the transformation system, which is used by TransformableNode for detecting gestures and coordinating which node is selected.
abstract boolean
isArRequired()
Returns true if this application is AR Required, false if AR Optional.
View
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
void
void
void
onPeekTouch(HitTestResult hitTestResult, MotionEvent motionEvent)
Called when a touch event is dispatched to a scene.
void
onRequestPermissionsResult(int requestCode, String[] permissions, int[] results)
Receives the results for permission requests.
void
void
onUpdate(FrameTime frameTime)
Called once per frame right before the Scene is updated.
void
setOnTapArPlaneListener(BaseArFragment.OnTapArPlaneListener onTapArPlaneListener)
Registers a callback to be invoked when an ARCore Plane is tapped.

Protected Methods

Boolean
getCanRequestDangerousPermissions()
If true, requestDangerousPermissions() returns without doing anything, if false permissions will be requested
abstract Config
abstract void
final void
initializeSession()
Initializes the ARCore session.
TransformationSystem
makeTransformationSystem()
Creates the transformation system used by this fragment.
void
onWindowFocusChanged(boolean hasFocus)
void
requestDangerousPermissions()
Starts the process of requesting dangerous permissions.
void
setCanRequestDangerousPermissions(Boolean canRequestDangerousPermissions)
If true, requestDangerousPermissions() returns without doing anything, if false permissions will be requested

Inherited Methods

Public Constructors

public BaseArFragment ()

Public Methods

public abstract String[] getAdditionalPermissions ()

Returns an array of dangerous permissions that are required by the app in addition to Manifest.permission.CAMERA, which is needed by ARCore. If no additional permissions are needed, an empty array should be returned.

public ArSceneView getArSceneView ()

Gets the ArSceneView for this fragment.

public PlaneDiscoveryController getPlaneDiscoveryController ()

Gets the plane discovery controller, which displays instructions for how to scan for planes.

public TransformationSystem getTransformationSystem ()

Gets the transformation system, which is used by TransformableNode for detecting gestures and coordinating which node is selected.

public abstract boolean isArRequired ()

Returns true if this application is AR Required, false if AR Optional. This is called when initializing the application and the session.

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

Parameters
inflater
container
savedInstanceState

public void onDestroy ()

public void onPause ()

public void onPeekTouch (HitTestResult hitTestResult, MotionEvent motionEvent)

Called when a touch event is dispatched to a scene. The callback will be invoked before the Scene.OnTouchListener is invoked. This is invoked even if the gesture was consumed, making it possible to observe all motion events dispatched to the scene. This is called even if the touch is not over a node, in which case getNode() will be null.

Parameters
hitTestResult represents the node that was touched
motionEvent the motion event

public void onRequestPermissionsResult (int requestCode, String[] permissions, int[] results)

Receives the results for permission requests.

Brings up a dialog to request permissions. The dialog can send the user to the Settings app, or finish the activity.

Parameters
requestCode
permissions
results

public void onResume ()

public void onUpdate (FrameTime frameTime)

Called once per frame right before the Scene is updated.

Parameters
frameTime provides time information for the current frame

public void setOnTapArPlaneListener (BaseArFragment.OnTapArPlaneListener onTapArPlaneListener)

Registers a callback to be invoked when an ARCore Plane is tapped. The callback will only be invoked if no Node was tapped.

Parameters
onTapArPlaneListener the BaseArFragment.OnTapArPlaneListener to attach

Protected Methods

protected Boolean getCanRequestDangerousPermissions ()

If true, requestDangerousPermissions() returns without doing anything, if false permissions will be requested

protected abstract Config getSessionConfiguration (Session session)

Parameters
session

protected abstract void handleSessionException (UnavailableException sessionException)

Parameters
sessionException

protected final void initializeSession ()

Initializes the ARCore session. The CAMERA permission is checked before checking the installation state of ARCore. Once the permissions and installation are OK, the method #getSessionConfiguration(Session session) is called to get the session configuration to use. Sceneform requires that the ARCore session be updated using LATEST_CAMERA_IMAGE to avoid blocking while drawing. This mode is set on the configuration object returned from the subclass.

protected TransformationSystem makeTransformationSystem ()

Creates the transformation system used by this fragment. Can be overridden to create a custom transformation system.

protected void onWindowFocusChanged (boolean hasFocus)

Parameters
hasFocus

protected void requestDangerousPermissions ()

Starts the process of requesting dangerous permissions. This combines the CAMERA permission required of ARCore and any permissions returned from getAdditionalPermissions(). There is no specific processing on the result of the request, subclasses can override onRequestPermissionsResult() if additional processing is needed.

setCanRequestDangerousPermissions(Boolean) can stop this function from doing anything.

protected void setCanRequestDangerousPermissions (Boolean canRequestDangerousPermissions)

If true, requestDangerousPermissions() returns without doing anything, if false permissions will be requested

Parameters
canRequestDangerousPermissions

Send feedback about...