I’m trying to learn the way integrating facebook in your application it works.
So, until now I found out how to retrieve user’s name or gender but I’m not able to found out his hometown.
Here is how I did it:
mRequestButton = (Button) findViewById(R.id.requestButton);
mRequestButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mAsyncRunner.request("me", new SampleRequestListener());
}
});
public class SampleRequestListener extends BaseRequestListener {
..........
JSONObject json = Util.parseJson(response);
final String name = json.getString("name");
final String locale=json.getString("locale");
..........
}
Now I was able to find both name and locale but when I do try to find the hometown doing like:
final String hometown=json.getString("hometown");
This string is empty….does anyone know how is the proper way to find the hometown???In here :https://developers.facebook.com/docs/reference/api/user/ it says that for finding out the hometown I need permissions….how I get those permissions???Can anyone tell me and posts o few lines of code?Thank u!
The hometown is another JSONObject which contains 2 strings, ID and name, so you want to extract the JSONObject called “hometown” then use
json.getString("name");to extract the name of the hometown.Example: