I want to incorporate a google map in my online grocery system in my android application in java. Which activity should I use to incorporate it. I am just starting my project to build. I am confused that from which activity should I start?
I have make an app which uses google map separately through google map activity. But this time, I want to add it in a huge project. Can I use main activity for incorporating google maps?
CodePudding user response:
Firstly, you should make single activity apps and display different fragments in your app. For example, you might have a login fragment and a groceries fragment (that displays all groceries or/and groceries filters), etc. You should put your Google map MapView in a fragment or use a premade Google maps fragment.
Remember MapView has its lifecycle that you will have to override. Other than that using MapView is pretty straightforward.
But if you insist on using activities you can use the MapActivity class, which is a subclass of Activity. This class provides a framework for displaying a map, and you can customize the appearance and behavior of the map using the MapView class.
You also need to implement the OnMapReadyCallback interface and override the onMapReady() method to set up the map and add any markers or other features to it.
I would recommend reading the documentation and watching a few videos on the topic.
MAPS DOCUMENTATION: https://developers.google.com/maps/documentation/android-sdk/start