Issue
I want to set google mapView API key in my java code, not in xml
many answers in stackoverflow say this can be achieved by using "new MapView(Context, API string)
"
but there's no such a "MapView(Context, String)
" method
all four constructors for mapview are:
MapView(Context)
MapView(Context, AttributeSet)
MapView(Context, AttributeSet, int)
MapView(Context, GoogleMapOptions)
I'm using the latest Google Play services lib (r14), Google Map View v2
the reason I must set API key dynamiclly is that my company is worried about if the key is unavailable some day, the program will not be able to show the google map. so we write the key in a text file, and every time the program starts, it will read a new text file from server. So if the previous key is unavailable some day(for example, google stop the free key service and demand all customers to pay for a commercial key), we can change the text file in server and all our program will get the new key and runs fine.
any ideas? Thanks in advance.
Solution
Again, AFAIK, this is not possible.
Moreover, the argument for why your company wants to do this is unrealistic IMHO. It is unlikely, in the scenarios that you describe, that replacing a key alone would have any effect. Rather, IMHO, it is far more likely that you would need to update the entire app, to integrate some new version of the Play Services SDK, perhaps in addition to replacing the key.
So, leave the key in the manifest, since you have no choice, and make sure that the company is in position to update its app as needed, whether for these sorts of Maps V2 disaster scenarios, or simply to improve the app.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.