Place Autocomplete for autocomplete textview - android

I'm trying to give auto suggestion for places when user typing in auto complete text view in android. Right now i'm using the new Google play services libraries and sample code from the following link Place Auto complete . But When trying to give suggestion for the user typed text, I'm getting the following error
Error getting autocomplete prediction API call:
Status { statusCode = NETWORK_ERROR, resolution = null }
Any idea what may be the problem?

I have found this: "public static final int NETWORK_ERROR
A network error occurred. Retrying should resolve the problem.
Constant Value: 7 (0x00000007) " see here.

Related

Googlesheet with Flutter : invalid_grant Invalid JWT

So, I've spent the past 2 hours searching for a solution for this but I cannot get anywhere.
I've followed this link to setup the google sheet API in order to use it with Flutter.
I keep getting this error:
ServerRequestFailedException (Failed to obtain access credentials. Error: invalid_grant Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim. Status code: 400)
As far as I've seen, this is related to a time problem but I've made sure the device's time is correct + enabled auto setting in the settings.
I'm using an android emulator (Pixel 4 API 27)
These are 2 pictures to show my time settings:
My code: (I'm calling the initSheet() in main)
class SpreadSheet {
static late final gsheets;
static late final spreadsheet;
static Future<bool> initSheet() async {
// TODO: Handle errors (Wrong time....)
gsheets = GSheets(_credentials);
/// link looks like so https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit#gid=0
/// [YOUR_SPREADSHEET_ID] in the path is the id your need
spreadsheet = await gsheets
.spreadsheet("1t51H_CSHPFoKB7KW_AcGMi3gwyJnecfM_k5wvk4OQ04");
return (spreadsheet == null ? false : true);
}
}
Somehow, the code is running perfectly now.
I used flutter clean & had to re-download gradle-6.9 zip because it got corrupted somehow.
I still don't know if that's exactly what actually fixed it or no but it'll be worth the try if someone faces this problem again.

What is a Page ID for the place field in Post Facebook Graph API?

I am having trouble while trying to post a message on the current end-user Facebook wall with my Android Application.
So far :
The user is logged in with all the required permissions, especially
the publish_actions permission ;
I am using the last version of Facebook SDK 3.x & Graph API v2 as of May 2014
Post to wall works now as of EDIT 2, but there are issues with
privacy settings : post cannot be seen by anyone not even the
recipient who is tagged in the post ! See EDIT 2 for more details
Here is the documentation for posting a message on the user wall :
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed (go to Publishing)
Regarding the message that needs to be posted on the user' wall, I need to tag some friends that were previously selected by the user.
But to use the tag field I need to use the place field.
The documentation says :
Name: tags
Comma-separated list of user IDs of people tagged in this post. You cannot specify this field without also specifying a place.
Type: csv[string]
Name: place
Page ID of a location associated with this post.
Type: string
What is location page ID ? How do I get it ?
Oddly enough, in my specefic case, I am offering the possibilty to the user to share is upcoming travel on Facebook.
More oddly enough, this travel is defined by dates and a destination (name of destination + latitude & longitude). The user has the possibility to also share this travel to his friends that are located in his travel's destination hence the need to tag his friends to the wall post.
[EDIT 1]
After looking into #Tobi solutions, I managed to post a message on the end-user wall (in my case me, since I am the developper).
So far : the message is correctly displayed with a friend tagged (a dummy account I use for tests purpouses) and there is also the place : Paris, France.
Using the following search query (thanks #Tobi) search?q=Paris,France&type=place I can get the ID of Paris, France.
Since I did not code the part to retrieve the Place ID it put it manually in the code for the sake of testing the feature first.
[END OF EDIT 1]
[EDIT 2]
I noticed I forgot to add the part with the privacy values to my args Bundle. But it did not change a damn thing : my post is only visible to me alone.
Going to my Facebook wall, here is what I get :
Hovering the public parameters of the posts (a padlock icon) says "All tagged persons".
Clicking on the icon shows the list of settings with only "Only me" selected.
Why "only me" even though I specifically said me + my dummy account in the request parameters ?
Even weirder : changing the property of the publication parameters to "customized" with my dummy account does not change a damn thing as well. Just why ? Facebook is really getting on my nerve...
For the rest, the message content is correctly displayed and the related place is the good one. At least a got that correctly. But still, I just don't get the rest ...
[END OF EDIT 2]
So here is the updated code :
if (this.session != null && this.session.isOpened()) {
final Bundle args = new Bundle();
if (this.selectedContacts.isEmpty() == false) {
args.putString("message", message);
args.putString("place", "170558129707208"); //manually added Paris, France ID
String tags = "";
//here I made some modifications regarding the tags so that is built correctly
for (int it = 0; it < this.selectedContacts.size(); it++) {
final String name = this.selectedContacts.get(it).toString();
final String friendID = String.valueOf(getIdFromName(name)); // returns an int
if (it == this.selectedContacts.size())
tags += friendID;
else
tags += friendID + ",";
}
// Forgot to add privacy values to bundle !
final JSONObject privacyValues = new JSONObject(); //not android JSON, but JSON-Simple lib
privacyValues.put("value", "CUSTOM");
String allow = this.currentUser.getId() + "," + tags;
privacyValues.put("allow", allow); // to limit the visibility of this post
args.putString("privacy", privacyValues.toJSONString()); //forgot that one...
final Request shareTravelRequest = new Request(this.session, this.currentUser.getID() + "/feed",
args, HttpMethod.POST, new Request.Callback() {
public final void onCompleted(final Response response) {
//TODO
}
}
);
final Response response = shareTravelRequest.executeAndWait();
if (response.getError() == null) // in this case, no error occurred
return true;
else {
this.lastErrorMessage = response.getError().getErrorMessage();
Log.e("Something went wrong while posting Facebook message", this.lastErrorMessage);
Log.e("Error type is", response.getError().getErrorType());
Log.e("Error code is", String.valueOf(response.getError().getErrorCode()));
return false;
}
}
}
Unfortunately I must have mistaken somewhere because although the post does appear on my Facebook wall with my dummy account tagged and with the correct link to the place, my dummy account cannot see the post.
I tried creating manually the same post on my Facebook wall by using the following settings :
First I supplied a message
Second I supplied a place
Third I tagged my dummy account
Four I choose who can see this post : me and my dummy account
And finally, I post the message.
In this case, my dummy account sees the post both on its wall and on my wall.
So I would like to know what parameters I must get wrong because there is not much parameters and I just don't see why.
Thanks !
You can either use the Search and use the type place (https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0#search), or, if you have positioning date, use an FQL query on the place table (https://developers.facebook.com/docs/reference/fql/place/) as described here: Facebook places: order results by distance
Use two test accounts made via Facebook Developer App settings and not a dummy account that breaks TOS. Since you request publish_actions you probably didn't submit the app for review. Unless your dummy account is a developer/tester in roles as well (which is breaking the TOS again) then your dummy account will not be able to see the post.
Only developers and testers of an unpublished application can see posts made by that application.

Google Spreadsheet API - Java - com.google.gdata.util.ParseException: Unrecognized content type:application/binary

I am using Google Spreadsheet API in my simple Android application. This is the piece of code:
URL spreadSheetUrl = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full");
SpreadsheetQuery query = new SpreadsheetQuery(spreadSheetUrl);
query.setTitleQuery("xyz");
query.setTitleExact(true);
SpreadsheetFeed spreadSheetFeed = service.getFeed(query, SpreadsheetFeed.class);
This piece of code is called from my application's sync adapter.
I am getting this error:
com.google.gdata.util.ParseException: Unrecognized content type:application/binary
com.google.gdata.client.Service.parseResponseData(Service.java:2136)
com.google.gdata.client.Service.parseResponseData(Service.java:2098)
com.google.gdata.client.Service.getFeed(Service.java:1136)
com.google.gdata.client.Service.getFeed(Service.java:1077)
com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
com.google.gdata.client.Service.getFeed(Service.java:1034)
Can someone suggest how I can solve this issue?
It turns out that I did not set the user credentials before executing this piece of code.
service.setUserCredentials(user, password);
Adding this line helped solve this issue. Weird.

Getting Gender of People in Google + in android

I have been trying to create an android app where I could Use Google + login. When I try to get data from the Google +, I am getting Gender as Male ("0") for all Google + users despite their Gender being Female in the actual Google + page.
Is this a bug from Google plus, or Is their anything like permission needed ?
^^^^^^^^Edit^^^^^^^^^^^^^^
I called mPlusClient.connect();
and then in the onConnected() I called mPlusClient.loadVisiblePeople(this, null);
In the onPeopleLoaded method I called personBuffer.get(i).getGender().
I am getting the gender as 0.
Note: I am getting the Display name , Profile Image in the same way as getting Gender and It is working fine.
Finally it worked. Need to add permissions to access gender and other details of people within the circle. The code snippet is:
mPlusClient = new PlusClient.Builder(this, this, this).setActions(
"http://schemas.google.com/AddActivity",
"http://schemas.google.com/BuyActivity").setScopes(Scopes.PLUS_LOGIN,Scopes.PLUS_PROFILE).build();

cannot implement rest webservice in android app

I want to implement rest webservice in android application
to do that
I create the class from this tutorial: here
but when I clcok on the matched button I have the error
unfortunetly, android app has stopped
I don't have anything in the Logcat
then I canno't know from which is the problem
here is the event code:
case R.id.btn_rest_test :
Log.d("method event get", "execite :)");
Rest r = new Rest();
r.get("http://www.cheesejedi.com/rest_services/get_big_cheese.php?puzzle=1");
r.getResponseString();
EditText etdit = (EditText) findViewById(R.id.rest_text);
EditText etdit2 = (EditText) findViewById(R.id.rest_error_text);
etdit.setText(r.getResponseText());
etdit2.setText(r.getError());
break;
how can I achieve that
This could be due to a lot of errors.
Are you sure it does not crash because of your two EditTexts not being found?
etdit.setText would cause NullPointerExceptions.
Did u try to check the response Its something like this:
[{"id":"755","level":"1","time_in_secs":"3","par":"0","initials":"KiB","quote":"Got'cha!","time_stamp":"2012-04-09 22:50:52"},{"id":"977","level":"1","time_in_secs":"3","par":"0","initials":"WJF","quote":"dats right numero uno","time_stamp":"2013-03-11 02:29:36"},{"id":"874","level":"1","time_in_secs":"3","par":"0","initials":"WJF","quote":"Look, Ma. No hands!","time_stamp":"2012-05-25 15:44:10"},{"id":"59","level":"1","time_in_secs":"4","par":"0","initials":"TMF","quote":"Hey hey ole ' hickery","time_stamp":"2012-03-03 04:36:15"},{"id":"61","level":"1","time_in_secs":"4","par":"0","initials":"WJF","quote":"I'm on a boat!","time_stamp":"2012-03-03 04:38:54"}]
As you can see its not ResponseString its a ResponseArray. Modify it accordingly.
Also check whether it type is POST or GET

Categories

Resources