{"_id":"5ba1a04d4f89f700039d85ce","project":"5a065a6134873d0010b396ab","version":{"_id":"5ba1a04d4f89f700039d85d0","project":"5a065a6134873d0010b396ab","__v":0,"forked_from":"5b8469fbe0a7ea00039d96b8","createdAt":"2018-04-18T18:19:34.288Z","releaseDate":"2018-04-18T18:19:34.288Z","categories":["5ba1a04d4f89f700039d8594","5ba1a04d4f89f700039d8595","5ba1a04d4f89f700039d8596","5b05923ea5a2f9000357b452","5b05f793c2c86c0003cbe414","5ba1a04d4f89f700039d8597","5ba1a04d4f89f700039d8598","5ba1a04d4f89f700039d8599"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.11.0","version":"1.11.0"},"category":{"_id":"5ba1a04d4f89f700039d8597","project":"5a065a6134873d0010b396ab","version":"5ba1a04d4f89f700039d85d0","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2018-05-24T14:09:29.251Z","from_sync":false,"order":2,"slug":"develop-ar","title":"Augmented Reality"},"user":"579a69d53de0a217007eda56","githubsync":"","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-05-24T15:45:06.391Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"The following guide details how to setup an AR application.\n[block:api-header]\n{\n  \"title\": \"Device Support\"\n}\n[/block]\nAR is not supported on all platforms. The full list of devices supporting AR can be found on Google's [ARCore page](https://developers.google.com/ar/discover/supported-devices). To programmatically detect if a device supports ARCore, use the [ViroViewARCore.isDeviceCompatible(Context)][1] method. If a given device isn't compatible, an UnavailableDeviceNotCompatibleException will be thrown if you attempt to construct a ViroViewARCore.\n\nIf a device *is* compatible, then when the ViroViewARCore is constructed users will be prompted to download ARCore, if they haven't already. This is an asynchronous flow that you can listen to by passing a [StartupListener](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewScene.StartupListener.html) into the ViroViewARCore constructor. If the download and install of ARCore was successful, the StartupListener's onSuccess() callback will be invoked. Otherwise, onFailure() will be invoked with the corresponding error code.\n\nTo summarize, the workflow is as follows:\n\n[1]:https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewARCore.html#isDeviceCompatible(android.content.Context)\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/759447f-Install_Flow.jpeg\",\n        \"Install Flow.jpeg\",\n        1024,\n        768,\n        \"#fbfbfb\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Required Camera Permissions for AR\"\n}\n[/block]\nViroCore requires access to the device's camera for AR enabled features like tracking / SLAM to function properly. This permission check automatically occurs during the onActivityResumed phase within the ViroViewARCore view. If the user has already previously given Camera permissions for your application, everything should work as per normal. \n\nHowever, if no camera permissions have yet been given, Viro will automatically ask for Camera permissions via Android's requestPermissions() API. This should pop up a friendly permission request dialog as shown below:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7105a1c-Permissions.png\",\n        \"Permissions.png\",\n        248,\n        172,\n        \"#0c0c0c\"\n      ]\n    }\n  ]\n}\n[/block]\nIf user then denies camera permissions, the StartupListener's onFailure() callback will be invoked with the corresponding CAMERA_PERMISSIONS_NOT_GRANTED error code. Note that like other Android permissions, you can also preemptively call and check for Camera permissions within your Android application before constructing the ViroViewARCore control.","excerpt":"","slug":"ar-setup","type":"basic","title":"Setup"}
The following guide details how to setup an AR application. [block:api-header] { "title": "Device Support" } [/block] AR is not supported on all platforms. The full list of devices supporting AR can be found on Google's [ARCore page](https://developers.google.com/ar/discover/supported-devices). To programmatically detect if a device supports ARCore, use the [ViroViewARCore.isDeviceCompatible(Context)][1] method. If a given device isn't compatible, an UnavailableDeviceNotCompatibleException will be thrown if you attempt to construct a ViroViewARCore. If a device *is* compatible, then when the ViroViewARCore is constructed users will be prompted to download ARCore, if they haven't already. This is an asynchronous flow that you can listen to by passing a [StartupListener](https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewScene.StartupListener.html) into the ViroViewARCore constructor. If the download and install of ARCore was successful, the StartupListener's onSuccess() callback will be invoked. Otherwise, onFailure() will be invoked with the corresponding error code. To summarize, the workflow is as follows: [1]:https://developer.viromedia.com/virocore/reference/com/viro/core/ViroViewARCore.html#isDeviceCompatible(android.content.Context) [block:image] { "images": [ { "image": [ "https://files.readme.io/759447f-Install_Flow.jpeg", "Install Flow.jpeg", 1024, 768, "#fbfbfb" ] } ] } [/block] [block:api-header] { "title": "Required Camera Permissions for AR" } [/block] ViroCore requires access to the device's camera for AR enabled features like tracking / SLAM to function properly. This permission check automatically occurs during the onActivityResumed phase within the ViroViewARCore view. If the user has already previously given Camera permissions for your application, everything should work as per normal. However, if no camera permissions have yet been given, Viro will automatically ask for Camera permissions via Android's requestPermissions() API. This should pop up a friendly permission request dialog as shown below: [block:image] { "images": [ { "image": [ "https://files.readme.io/7105a1c-Permissions.png", "Permissions.png", 248, 172, "#0c0c0c" ] } ] } [/block] If user then denies camera permissions, the StartupListener's onFailure() callback will be invoked with the corresponding CAMERA_PERMISSIONS_NOT_GRANTED error code. Note that like other Android permissions, you can also preemptively call and check for Camera permissions within your Android application before constructing the ViroViewARCore control.