Sample app that displays your favorite places.
- Android SDK
- Android Build Tools
- Android Support Repository
- Google Maps Platform API (Places SDK for Android)
This sample uses Gradle buid system in Android Studio.
Follow through the folders above to get an idea about where to use each code. Detailed guide given below.
Step 1: Under activities the MainActivity file is automatically created. Copy the code from MainActivity.kt from here and paste it in your file.
Step 2: Under activities, create three more files namely, AddHappyPlaceActivity, AddHappyPlaceDetailActivity and MapActivity. Copy the codes from the files with the same name from here.
Step 3: Under com.example.yourProjectName create four more folders, adapters, database, models and utils and one file namely, MapFragments. In the adapters folder create a HappyPlacesAdapter file, under database create DatabaseHandler file, under models create HappyPlaceModel file and under utils create GetAddressFromLatLng, SwipeTodeleteCallback and SwipeToEditCallback files.
Step 4: Copy the following codes from the files with name name from here and paste it in your files.
These are the actual main codes for the app. You can stylisize your app according to your needs using the XML files. I hvae attached my own files also, to use them read along.
Under app, in res folder, in drawable folder, add the followinf files:
- Both the image files.
- ic_action_add_24dp, ic_delete_sweep_24dp, ic_edit_icon_24dp, ic_launcher_background, ic_launcher_foreground, shape_button_rounded and shape_image_view_border.
Under layout in the res folder, add the following files: activity_add_happy_place, activity_happy_place_detail, activity_main, activity_map, fragment_maps and item_happy_place.
Under values in the res folder, add the following files: colors, dimens, strings, styles and ic_launcher_background. In this same folder, you also need to add the "google_maps_api.xml" file, which will be provided by Google Maps API platform. Also in the strings file, you will need to add you API KEY which will be provided by Maps API again.
Images used are license free.
https://developers.google.com/maps/apis-by-platform
Go to the above link and select Places SDK for Android. Go through Using API Keys tab and follow the instructions for setup. Use the key generated in your app in the strings.xml file.