Unfortunately, I could not find the answer for Android Place Picker closes immediately after launch . For me, PlacePicker launches, shows the location as Unknown, and then returns with resultCode 2.
To confirm some truths: my application has two actions so far. The first action is a card that still works fine; no problem. The second action has a button that allows the user to launch PlacePicker. The fact that the first action launches the map without any problems should confirm to the reader that my manifest is beautiful and that my Google Api Console has the correct data. So this leaves me: what am I doing wrong? I use an exact example like https://developers.google.com/places/android-api/placepicker . Actually here is my code
try { IntentBuilder builder = new IntentBuilder(); startActivityForResult(builder.build(this), REQUEST_PLACE_PICKER); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); }
and then
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (RESULT_OK != resultCode) { Log.d(TAG,"bad result: "+resultCode); return; } if (REQUEST_PLACE_PICKER == requestCode) { Place place = PlacePicker.getPlace(data, this); String toastMsg = String.format("Place: %s", place.getName()); Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show(); } }
and here is my complete magazine
D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! D/AddLocationActivity: bad result: 2
android android-intent google-maps google-places-api startactivityforresult
Katedral pillon
source share