Try This It's Work For me
login.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
if (AccessToken.getCurrentAccessToken() != null) {
RequestData();
}
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException exception) {
}
});
private void RequestData() {
GraphRequest request = GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object,GraphResponse response) {
final JSONObject json = response.getJSONObject();
try {
if(json != null){
text = "<b>Name :</b> "+json.getString("name")+"<br><br><b>Email :</b> "+json.getString("email")+"<br><br><b>Profile link :</b> "+json.getString("link");
/*details_txt.setText(Html.fromHtml(text));
profile.setProfileId(json.getString("id"));*/
Log.e(TAG, json.getString("name"));
Log.e(TAG, json.getString("email"));
Log.e(TAG, json.getString("id"));
//web.loadData(text, "text/html", "UTF-8");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link,email,picture");
request.setParameters(parameters);
request.executeAsync();
}
//Get Profile Picture from id
public static Bitmap getFacebookProfilePicture(String userID){
try {
URL imageURL = new URL("https://graph.facebook.com/" + userID + "/picture?type=large");
Log.e(TAG,imageURL.toString());
try {
bitmap = BitmapFactory.decodeStream(imageURL.openConnection().getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return bitmap;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…