在 Android Studio 中,打开 GeospatialActivity 并浏览到
以下部分:
// The thresholds that are required for horizontal and heading accuracies before entering into the// LOCALIZED state. Once the accuracies are equal or less than these values, the app will// allow the user to place anchors.privatestaticfinaldoubleLOCALIZING_HORIZONTAL_ACCURACY_THRESHOLD_METERS=10;privatestaticfinaldoubleLOCALIZING_HEADING_ACCURACY_THRESHOLD_DEGREES=15;
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThis quickstart provides instructions for running a sample Android app that demonstrates Google's ARCore Geospatial API.\u003c/p\u003e\n"],["\u003cp\u003eTo use the app and API, you'll need a supported Android device with specific hardware and software requirements, including Android Studio and the ARCore SDK.\u003c/p\u003e\n"],["\u003cp\u003eYou need to set up a Google Cloud Project and enable the ARCore API to utilize the Visual Positioning System (VPS) within the app.\u003c/p\u003e\n"],["\u003cp\u003eThe sample app showcases how to obtain geospatial pose data and place anchors in the real world, with varying accuracy depending on environmental factors and VPS availability.\u003c/p\u003e\n"],["\u003cp\u003eFurther resources include a Geospatial codelab and detailed developer guides to help you build your own AR applications using the Geospatial API.\u003c/p\u003e\n"]]],["This document guides users to set up and run a sample app demonstrating the ARCore Geospatial API. Key actions include downloading the ARCore SDK, opening the `geospatial_java` project in Android Studio, and setting up a Google Cloud Project for VPS authorization. Users then run the app to view a camera feed with Geospatial pose debug data, and place Anchors when ARCore is confident of location and heading. Users can adjust accuracy thresholds in `GeospatialActivity` if VPS or GPS signals are insufficient.\n"],null,["# Geospatial quickstart for Android\n\nYour browser does not support the video tag.\n\n\u003cbr /\u003e\n\nThis quickstart for the ARCore Geospatial API shows you how to run a sample app\nin Android Studio that demonstrates the Geospatial API.\n\nFor a guide to developing your own app with the Geospatial API, see the\n[Geospatial developer guide for Android (Kotlin/Java)](/ar/develop/java/geospatial/developer-guide)\nor the\n[Geospatial developer guide for Android NDK (C)](/ar/develop/c/geospatial/developer-guide).\n\nSee the\n[Introduction to the ARCore Geospatial API](/ar/develop/geospatial) for more\ninformation about the Geospatial API.\n\nIf you're new to developing with ARCore, see [Getting started](/ar/develop/getting-started).\n\nRequirements\n------------\n\n### Device support\n\nSee [Supported devices](/ar/devices) for a complete list of devices that\nhave been certified to work with ARCore. For the Geospatial API, one of the key\npieces of hardware required is a magnetometer that meets the Geospatial API\nspecifications. Some magnetometers do not meet the spec; devices with these\noff-spec magnetometers are not supported.\n\n### Software\n\n- The latest version of\n [Google Play Services for AR](https://play.google.com/store/apps/details?id=com.google.ar.core)\n installed on the [supported device](/ar/devices).\n\n- [Android Studio](https://developer.android.com/studio) version 3.0 or later\n with Android SDK Platform version 7.0 (API level 24) or higher\n\n- The ARCore SDK for Android, which you can get in one of two ways:\n\n - Download it from\n [GitHub](https://github.com/google-ar/arcore-android-sdk)\n and extract it on your machine.\n\n - Clone the repository with the following command:\n\n ```\n git clone https://github.com/google-ar/arcore-android-sdk.git\n ```\n\n \u003cbr /\u003e\n\nOpen and set up the sample app\n------------------------------\n\nThe **geospatial_java** project included with the ARCore SDK for Android\ndescribes code that calls the Geospatial API.\n\n1. In Android Studio, from the **File** menu, click **Open**.\n\n2. Navigate to the project folder for the **arcore-android-sdk**.\n\n3. Open the **samples** folder, select the **geospatial_java** folder, and\n click **Open**.\n\n### Set up a Google Cloud Project\n\nTo use the Visual Positioning System (VPS), your app needs to be associated with\na Google Cloud Project that is enabled for the ARCore API. See\n[Use the ARCore API on Google Cloud](/ar/develop/authorization?platform=android)\nto set up authorization. You can choose either Keyless or API Key authorization.\n\nRun the sample app\n------------------\n\nIn Android Studio, run the sample app.\n\nYou should be able to see a camera view, along with debug information describing\nthe current Geospatial pose of your device. As you scan the environment around you,\nnotice the positioning accuracy confidence values may change as you move around,\nif you're in an area supported by VPS localisation.\n\nWhen ARCore is confident in your device's location and heading, you can place an\nAnchor at your current location using the Geospatial pose.\n\nThe positioning accuracy may be too low if VPS information is unavailable. The\napp must be connected to the internet, and the location must be known to the VPS.\nFor best results, run the sample app outside (not indoors) during daylight hours.\n\nAlso, if you are in an area that does not support VPS, or if GPS signals aren't\nsufficient, you may need to adjust the confidence thresholds in the app in order\nto place an anchor.\n\nTo adjust the thresholds:\n\n1. In Android Studio, open the **GeospatialActivity** and browse to the\n following section:\n\n // The thresholds that are required for horizontal and heading accuracies before entering into the\n // LOCALIZED state. Once the accuracies are equal or less than these values, the app will\n // allow the user to place anchors.\n private static final double LOCALIZING_HORIZONTAL_ACCURACY_THRESHOLD_METERS = 10;\n private static final double LOCALIZING_HEADING_ACCURACY_THRESHOLD_DEGREES = 15;\n\n2. Adjust these values as needed. The higher the value, the *lower* the accuracy.\n\n Lowering the accuracy allows the app greater *latitude* in placing an anchor.\n See\n [Adjust for pose accuracy](/ar/develop/java/geospatial/developer-guide#adjust-for-pose-accuracy)\n for more information.\n\nNext steps\n----------\n\n- Try the [Geospatial codelab](/ar/develop/java/geospatial/codelab).\n\n- Review the\n [Geospatial developer guide for Android (Kotlin/Java)](/ar/develop/java/geospatial/developer-guide)\n or the\n [Geospatial developer guide for Android NDK (C)](/ar/develop/c/geospatial/developer-guide),\n and get started building with the Geospatial API."]]