I am working on a android application in which I need to open a Facebook login window
and then after logging successfully, I need to move to another intent (or new screen)
.
So as soon as user is logged in successfully, it should go to another screen in my app. I am having a very hard time making this thing to work. I have got the sample examples from the Facebook SDK so I was testing it out on those examples, I created another screen named Screen2.java(new xml file)
having only a single button just to test it out.
So in my case what it should do is as soon as you are logged in successfully it should go to . Screen2 intent
. So I made some changes in the Main.java class
mentioned here in this tutorial but it is not working for me. Meaning as soon as I am logged in to Facebook, it doesn't goes to .Screen2 intent
that I have created. Can anyone help me out here?
I made changes only in Main.java class
as below by adding new Intent
in the method onAuthSucceed()
-
public class SampleAuthListener implements AuthListener {
@Override
public void onAuthSucceed() {
mText.setText("You have logged in! ");
// mRequestButton.setVisibility(View.VISIBLE);
// mUploadButton.setVisibility(View.VISIBLE);
// mPostButton.setVisibility(View.VISIBLE);
Intent i = new Intent(Main.this, Screen2.class);
startActivity(i);
}
@Override
public void onAuthFail(String error) {
mText.setText("Login Failed: " + error);
}
}
NOTE:- I am able to login into Facebook but after logging successfully, it doesn't goes to my new Intent.
Any help will be appreciated.
I was under the impression you needed something like this
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
}
};
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
Log.d(TAG, "Logged in...");
//fire intent
} else if (state.isClosed()) {
Log.d(TAG, "Logged out...");
}
}
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.