# Class AR

java.lang.Object
com.codename1.ar.AR

public final class AR extends Object

Entry point for the cross-platform augmented reality API.

AR sessions track the device's pose in the real world through the camera, detect surfaces, and composite virtual 3D content into the camera image. The typical flow: check `#isSupported()`, `#open(ARSessionOptions)` a session, add its `ARSession#createView()` to a form, then place content by hit testing taps against detected planes and hanging `ARNode`s on the resulting anchors.

Permissions and dependencies: simply referencing classes in this package causes the build pipeline to inject the camera permission, the `NSCameraUsageDescription` plist entry (iOS, override via the `ios.NSCameraUsageDescription` build hint) and the ARCore dependency (Android). Devices without AR support report `#isSupported()` false; always guard AR functionality behind that check.

    if (AR.isSupported()) {
        ARSession s = AR.open(new ARSessionOptions());
        Form f = new Form("AR", new BorderLayout());
        f.add(BorderLayout.CENTER, s.createView());
        f.show();
        // on tap: hit test and place a model
        s.hitTest(xNorm, yNorm).ready(hits -> {
            if (hits.length > 0) {
                ARAnchor a = hits[0].createAnchor();
                a.setNode(new ARNode(ARModel.fromGltf(modelBytes)));
            }
        });
    }

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ARCapabilities`
  `getCapabilities()`
  Returns which AR features this device supports.
  `static boolean`
  `isSupported()`
  True when the running platform has a working AR implementation.
  `static ARSession`
  `open(ARSessionOptions opts)`
  Opens an AR session.
  `static void`
  `requestPermissions(SuccessCallback<Boolean> callback)`
  Requests the camera permission needed for AR.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### isSupported

    public static boolean isSupported()
    True when the running platform has a working AR implementation. False on platforms and devices without AR support.

  - ### getCapabilities

    public static ARCapabilities getCapabilities()
    Returns which AR features this device supports. On unsupported platforms every capability reads false.

  - ### open

    public static ARSession open(ARSessionOptions opts)

    Opens an AR session. Throws `IllegalStateException` when AR is unsupported or a session is already open; close the old session first.

    ###### Parameters

    - `opts`: the session configuration; null uses the defaults

    ###### Returns

    the running session

  - ### requestPermissions

    public static void requestPermissions(SuccessCallback<Boolean> callback)

    Requests the camera permission needed for AR. The callback receives true when granted; it is invoked on the EDT.

    ###### Parameters

    - `callback`: receives the grant result; may be null