While trying to login an android application using Facebook login the app says logged in successfully and then closes however on searching about the same i came across some solutions but nothing helped.adding the code snip for reference.
/*login screen*/
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object,
GraphResponse response) {
String profilePicUrl="";
Log.i("LoginActivity", response.toString());
Log.i("LoginActivity", object.optString("name"));
Log.i("LoginActivity", object.optString("email"));
Log.i("LoginActivity", object.optString("id").toString());
try {
JSONObject data = response.getJSONObject();
Fb_fname= object.optString("name");
FbId=object.optString("id").toString();
if (data.has("picture")) {
profilePicUrl = data.getJSONObject("picture").getJSONObject("data").getString("url");
}
registerfacebook(Fb_fname,FbId,profilePicUrl);
} catch (Exception e) {
e.printStackTrace();
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email,gender, birthday,picture.type(large)");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
System.out.println("onCancel");
}
@Override
public void onError(FacebookException exception) {
System.out.println("onError");
}
});
and the code for the home screen is as follows.
/*home screen*/
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Log.i("Username","hii");
The above is a code module on the pages involved.Suggestions welcomed.
Most of the times if all goes good you can check the logout section as maybe you missed to end the login session created at the time of social login. In that case you would not be able to login efficiently so its recommended to handle the social login sessions at the time of logout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.