Kho lưu trữ mẫu SDK Địa điểm dành cho Android trên GitHub bao gồm các ứng dụng mẫu minh hoạ cách sử dụng SDK Địa điểm dành cho Android.
Nhập và tạo ứng dụng, thêm khoá API, xem bản minh hoạ và sử dụng mã mẫu được cung cấp làm điểm xuất phát cho ứng dụng.
Khi bạn chạy ứng dụng mẫu, ứng dụng này sẽ hiển thị danh sách các mẫu có sẵn mà bạn có thể chạy trên thiết bị của riêng mình. Chọn một trong các lựa chọn. Ví dụ: nhấp vào Tự động hoàn thành vị trí.
Sao chép và chạy các mẫu
Bạn cần có Git để chạy mẫu này trên máy. Lệnh sau đây sẽ sao chép kho lưu trữ ứng dụng mẫu.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[[["\u003cp\u003eThis page provides instructions for setting up and running sample apps that demonstrate the use of the Places SDK for Android.\u003c/p\u003e\n"],["\u003cp\u003eThe sample apps are available in both Kotlin and Java, accessible through a GitHub repository.\u003c/p\u003e\n"],["\u003cp\u003eYou'll need to clone the repository, import the project into Android Studio, and configure your API keys to run the examples.\u003c/p\u003e\n"],["\u003cp\u003eThe provided samples showcase various functionalities like Place Autocomplete, offering a starting point for developing your own Android apps with Places SDK.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting information is included if the map doesn't display, guiding you to verify the API key configuration.\u003c/p\u003e\n"]]],[],null,["# Places SDK for Android code samples\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/examples \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/examples \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/examples \"View this page for the JavaScript platform docs.\")\n\nThe Places SDK for Android samples repository on\n[GitHub](https://github.com/googlemaps-samples/android-places-demos)\nincludes sample apps that demonstrate the use of the Places SDK for Android.\nImport and build the app, add your API key, view the demo, and use the sample code supplied as a\nstarting point for your app.\n\nWhen you run the sample app, it displays a list of available samples that you can\nrun on your own device. Select one of the options. For example, click\n**Place Autocomplete**.\n| **Troubleshooting:** If the sample app runs successfully but you don't see a map, check that you've added your API key to the app's manifest file, as described in [Using API Keys](/maps/documentation/places/android-sdk/get-api-key).\n\nClone and run the samples\n-------------------------\n\nGit is required to run this sample locally. The following command clones the sample\napplication repository. \n\n```\ngit clone git@github.com:googlemaps-samples/android-places-demos.git\n```\n\nImport the sample project into Android Studio:\n\n1. In Android Studio, select **File \\\u003e New \\\u003e Import Project**.\n2. Go to the location where you saved the repository and select the project directory for\n Kotlin or Java:\n\n - **Kotlin** : \u003cvar translate=\"no\"\u003ePATH-REPO\u003c/var\u003e`/android-places-demos/demo-kotlin`\n - **Java** : \u003cvar translate=\"no\"\u003ePATH-REPO\u003c/var\u003e`/android-places-demos/demo-java`\n3. Select **Open**. Android Studio builds your project, using the Gradle build tool.\n4. In your top-level project directory, create a `secrets.properties` file.\n5. [Get an API key](/maps/documentation/places/android-sdk/get-api-key) from your project with the [Places API and/or Places API (New) enabled](/maps/documentation/places/android-sdk/cloud-setup#enabling-apis).\n6. In the `secrets.properties` file, add the following strings, replacing **YOUR_API_KEY** with the value of\n your API key:\n\n ```scdoc\n PLACES_API_KEY=YOUR_API_KEY\n MAPS_API_KEY=YOUR_API_KEY\n \n ```\n7. Run the app."]]