We are developing an Android application that uses google maps.
Right now, for development purposes, we're using the key like this:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
And
<string name="google_maps_key">KEY_HERE</string>
For deploying purposes, we will implement a "Bring Your Own Key" approach where each client that buys the product, also put his key to be used.
I know it's weird and somewhat unnecessary, but it is a process from a big company and this decision comes from "the top".
Is there any way that we can have dynamic keys? Like putting a key into a service and consuming it in the app or something like that?
Appreciate any help.
This is not possible in Google API V2 according to the documentation the API key has to be assigned using the Manifest file.
https://developers.google.com/maps/documentation/android/start#adding_the_api_key_to_your_application
But its possible for MapView.
If you are instantiating a MapView directly from the code, you should pass the Maps API Key in the MapView constructor.
Code:
@Override
protected void onCreate(.....) {
super.onCreate(....);
mMapView = new MapView(this, YOUR_MAP_API_KEY); //pass key to MapView Constructor here
setContentView(mMapView);
// ....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With