This is a problem that I've been stuck for weeks, but still, I can't solve it. My friend's google place picker worked, but not mine (even though we have the same code).
But once in 20-30 tries, it opens the UI lets me have a look at nearby places around my location (but that's a very very rare case).
I've done everything I possibly could.
1) I've enabled Google Places API for Android and generated my API key. I've also added my SHA-1 certificate fingerprint and package name.
2)I've imported everything related to google play services that I could in gradle.
implementation 'com.google.android.libraries.places:places-compat:1.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:26.+'
implementation 'com.google.android.gms:play-services-places:16.0.0'
3)I've also given my API key inside of meta-data in my application tag in AndroidManifest.xml
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_place_api" />
</application>
4)I've copied the exact code that I got from Place-picker documentation site https://developers.google.com/places/android-sdk/placepicker
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
try {
startActivityForResult(builder.build(maps.this), PLACE_PICKER_REQUEST);
} catch (
GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (
GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
#Override
protected void onActivityResult ( int requestCode, int resultCode, Intent data){
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(data, this);
String toastMsg = String.format("Place: %s", place.getName());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
}
}
5)I've even enabled billing for my project, where Google charged me Re 1.
This is very important for my project, so please someone help me. I beg of you.
Edit: I'm getting some kind of error in my logcat too:
Place Picker closing due to PLACES_API_ACCESS_NOT_CONFIGURED
the Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
2019-05-12 08:07:57.106 2818-3899/? E/Volley: [171] BasicNetwork.performRequest: Unexpected response code 403 for https://www.googleapis.com/placesandroid/v1/placePicker?key=AIzaSyCz-bC6nazJur-gHEgVoZMujFDyVvs2n9M
2019-05-12 08:07:57.110 2818-20254/? E/Places: Places API for Android does not seem to be enabled for your app. See https://developers.google.com/places/android/signup for more details.
2019-05-12 08:07:57.112 2818-20254/? E/AsyncOperation: serviceID=65, operation=PlacePickerQuota
EDIT#2: Is there any solution to this? Please answer me.
You seem not to have enabled place API, below is the link to the steps to get that done.
https://support.google.com/googleapi/answer/6158841?hl=en
if you check your logcat well enough, maybe by selecting the types of log you want to see, you can select Error instead of verbose, then you will see the error like below
E/Places: Places API for Android does not seem to be enabled for your app. See https://developers.google.com/places/android/signup for more details.
I believe the issue is related to the deprecated version of Places SDK for Android. You have the following statement in gradle
implementation 'com.google.android.gms:play-services-places:16.0.0'
This refers to the Google Play version of Places SDK, that was deprecared. In order to use new static library of Places SDK the gradle should use
implementation 'com.google.android.libraries.places:places:1.1.0'
Please double check all steps mentioned in the documentation of new library to be sure that you migrated to new version correctly:
https://developers.google.com/places/android-sdk/start
I hope this helps!
Related
I just updated my Google dependencies to 12.0.1 and now I'm getting this error where I'm using FusedLocationProviderClient.
Any idea why is this happening? Looking into source code, I can see the the constructors are now hidden:
#Hide
public FusedLocationProviderClient(#NonNull Context var1) {
super(var1, LocationServices.API, (ApiOptions)null, new zzg());
}
#Hide
public FusedLocationProviderClient(#NonNull Activity var1) {
super(var1, LocationServices.API, (ApiOptions)null, new zzg());
}
But it doesn't make sense. Why? Google obviously wanted people to migrate to this new Location Provider. Why would they suddenly make it unavailable? I've checked out the docs and I can't find anything about this.
Luckily the code still compiles and location works. But still...why?
The documentation could have been clearer, but it seems the intention is for you to call LocationServices.getFusedLocationProviderClient(). See the API here.
Upgrade to version 15.0.0 released on the 12th it will clear the warning for you. I don't see anything in release notes or bug reports mentioning this, so it is probably just a bug introduced in 12.0.1.
I am trying to submit a score at a Google Game Play Leaderboard using the following code line:
if(mGoogleApiClient.isConnected()) {
Games.Leaderboards.submitScoreImmediate(mGoogleApiClient, "xxxxxxxxxxxxxxxxx", myScore).setResultCallback(new ResultCallback<Leaderboards.SubmitScoreResult>() {
#Override
public void onResult(Leaderboards.SubmitScoreResult arg0) {
Log.e(TAG, "getStatusCode= "+arg0.getStatus().getStatusCode());
Log.e(TAG, "score submitted: "+arg0.getScoreData().toString());
}
});
}
The score is not uploaded and I get the following error ScoreSubmissionData:
ScoreSubmissionData{PlayerId=xxxxxxxxxxxxxxxx, StatusCode=2, TimesSpan=DAILY, Result=null, TimesSpan=WEEKLY, Result=null, TimesSpan=ALL_TIME, Result=null}
StatusCode=2 means STATUS_CLIENT_RECONNECT_REQUIRED
I call the above line inside onConnected() method so it is sure that I am connected...
Try reconnecting or apply a Loop-switch sequence to handle error like this. You might want to check this example showing how to use STATUS_CLIENT_RECONNECT_REQUIRED of the com.google.android.gms.games.GamesClient class.
Base on the document:
STATUS_CLIENT_RECONNECT_REQUIRED
The AppStateClient is in an inconsistent state and must reconnect to the service to resolve the issue.
Also here is the list of AppStateClient that you may encounter.
Hope this helps.
I have found the solution.
The application i make was first build to an other Laptop.
Now i have bought a new Laptop, i installed Android Studio and tried to change some code lines. But when i submitted a Score my Google play account (API Manager) could not recognize my new Laptop because it had a different SHA1 key.
So i added my new SHA1 key at the credentials of the API Manager and everything was ok !!
According to This Official Post
I'm following below steps to integrate Place Picker UI dialog with Map.
launcher code
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
inside onActivityResult()
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(this, data);
tvChooseLocation.setText(place.getName());
}
}
I have added all permissions & API_KEY in Manifest file
Problem is I am not able to select location from Place Picker dialog.
Select button is disabled by default.
I have solved this so I don't quite know which one of these steps solves it
In console.developer.google.com
I enable Places API and Maps API, and download the json from here.
Also, get the API key from Credential page.
In Android Studio
In manifest, add in between <application> ... </application>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_KEY_FROM_CREDENTIAL_PAGE"/>
In onCreate(), add this (though I don't quite sure this is needed or not)
private GoogleApiClient mGoogleApiClient;
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
Everything else just follow the tutorial in here. Also, I tested it in release version. If you still have the same problem, try make a release one. I failed to get the location in emulator but it work just fine in my phone.
Hopefully this can help anyone in the future.
Try enabling google places api from google developer console
Link to console
--Wanted to comment though but do not have permission.
I am unable to pick the location from place picker.
It disables the select button when select place but when to search location and pick then it enable select button.
I am using play services version
com.google.android.gms:play-services-location:9.4.0
and com.google.android.gms:play-services:9.4.0
btn_locationSend.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
try {
startActivityForResult(builder.build(ChatThreadActivity.this),PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
}
});
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case PLACE_PICKER_REQUEST:
Place place = PlacePicker.getPlace(this,data);
LatLng location = place.getLatLng();
String toastMsg = String.format("Place: %s", place.getName());
} }
If your problem is not solved yet. Enable Google Places API for Android in dev console.
It's because you didn't give permission to use Places on google maps. Just go to the link and enable Google Places API for Android.
It maybe a bit late but check out my answer to what sounds like the same problem (Disable select button while selecting location of anonymous location using Place picker google API in android)
Basically make sure that the API Key in your AndroidManifest.xml has the correct name. While com.google.android.maps.v2.API_KEY will work for the Maps API the Places API requires com.google.android.geo.API_KEY.
If you are using the Maps API then you can use the same key and both APIs will work using the latter kay name.
use this
<application>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
</application>
insted of this
com.google.android.maps.v2.API_KEY
The code looks fine. In fact, I tried re-running it and found no such observation; the SELECT button of the Use this location pop-up dialog was always enabled. However, when I manually disabled my Internet connection, the SELECT button became disabled. So, I believe, if your Internet connection is intermittent or has a problem, you might be able to observe the same thing.
I want to use Flickr API for downloading the images on Android Phone, can any one give or tell, me about the working sample of Flickr API on Andorid.
I have add the flickr.jar as the external library, and i have the "Key"and "Secret" but i do not know how to download the images.
All it takes is just 3 steps and you will have it implemented.
Step 1: Find your user id.
The easiest way is to use this service http://idgettr.com/
Step 2: Acquire you flickr api key
Just log-in to you account and click this link http://www.flickr.com/services/api/misc.api_keys.html
Step 3: Get the code from the example project from our blog
http://www.quintostdio.com/blog/archives/1117
Add you user id and api key on the FlickrActivity class (in the package com.quintostdio.test.flickr.ui) and run the example. You can copy paste the classes and add it to your project, with no more changes and it will work.
Hi I have built a Flickr Java library for Android: http://code.google.com/p/flickrj-android/
You'll need to look in their documentation on the Flickr site. Most likely will use the Java library and import it into your Android project.
Probably have to instantiate an object, using the Key and Secret. Once you have a valid authentication object, you'll use a provided method (from the docs) to get a picture.
Have a look here: http://www.flickr.com/services/api/
#Todd DeLand answer is pretty accurate even nowadays.
However, I'll speed you up the search and tell you that the flickrj-android is not anymore up to date, as you can check in the Downloads page https://code.google.com/archive/p/flickrj-android/downloads
The other project that is listed in the Flickr API page ( http://www.flickr.com/services/api/ ), Flickr4Java, it's definitely working nowadays since I just tested it today and so far is doing it's job pretty nicely.
Github repo: https://github.com/boncey/Flickr4Java
Gradle config to add in your project (be careful, since in the README it appears another Gradle configuration, which is for the project that Flickr4Java is based on, and is NOT working):
implementation "com.flickr4java:flickr4java:2.17"
As of today, Flickr4Java was last updated on Nov 11, 2017, which is not bad.
This is an example of how I sent a query to get the pictures around a certain location (latitude,longitude):
Thread thread = new Thread(new Runnable() {
#Override
public void run() {
try {
String apiKey = "MY_API_KEY";
String sharedSecret = "MI_API_SECRET";
REST rest = new REST();
Flickr flickrClient = new Flickr(apiKey, sharedSecret, rest);
SearchParameters searchParameters = new SearchParameters();
searchParameters.setLatitude(exampleLatitude);
searchParameters.setLongitude(exampleLongitude);
searchParameters.setRadius(3); // Km around the given location where to search pictures
PhotoList photos = flickrClient.getPhotosInterface().search(searchParameters,5,1);
} catch (Exception ex) {
Log.d(MapApplication.LOG_TAG, ex.getLocalizedMessage());
}
}
});
thread.start();
I would avoid flickr4java. I assumed it worked at first but after incorporating it in to my project I have found that it crashes the app intermittently. very annoying and has been a big waste of time :(. probably works fine under other java apps but does not seem to play well with android :(