I enabled Google Places API for Android in google console and put the API key in manifest file
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
in my activity
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
Intent intent = builder.build(KhetAdd.this);
startActivityForResult(intent, PLACE_PICKER_REQUEST_CODE);
and
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK) {
if (requestCode == PLACE_PICKER_REQUEST_CODE) {
final Place place = PlacePicker.getPlace(this, data);
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
}}}
This code is perfectly working in my android studio but when i am compiling this same code in other android studio, after launching immediately map is closing. Why is that ? Please help me out.
https://console.developers.google.com/
Select project -> Dashboard -> Enable API -> Google Maps APIs
Google Maps Android API
Google Places API for Android
andGoogle Maps Geocoding API
- Enable thiswait a minute to reflect,
Restart your app, Enjoy ;)