Android PlacePicker closes 2 seconds after launch

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 
+7
android android-intent google-maps google-places-api startactivityforresult
source share
2 answers

Please make sure you add the sha-1 key to the google api console.

How to get the SHA-1 fingerprint: https://developers.google.com/places/android-api/signup#debug-cert ideally you would add your SHA-1 debug key and your SHA-1 key to the console so that both key could use api.

You must go through the steps described on this page and make sure that you are not missing anything: https://developers.google.com/places/android-api/signup#api-console

0
source share

I solved this problem by logging into the Google Developer console. Then headed to Api> Dashboard, and then clicked on ENABLE APIS AND SERVICES.

Link to Google Developer Api Dashboard

0
source share

All Articles