Le dépôt d'exemples du SDK Places pour Android sur GitHub inclut des exemples d'applications qui illustrent l'utilisation du SDK Places pour Android.
Importez et créez l'application, ajoutez votre clé API, consultez la démonstration et utilisez l'exemple de code fourni comme point de départ pour votre application.
Lorsque vous exécutez l'application exemple, elle affiche la liste des exemples disponibles que vous pouvez exécuter sur votre appareil. Sélectionnez l'une des options proposées. Par exemple, cliquez sur Place Autocomplete.
Cloner et exécuter les exemples
Git est requis pour exécuter cet exemple en local. La commande suivante clone le dépôt de l'application exemple.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/29 (UTC).
[null,null,["Dernière mise à jour le 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."]]