How To Hide The Facebook Login Page Activity After Successful Login In Android?
I am a newbiew in Android. I have intergarted Facebook in my Android app. I have a Login page with a button. On click of that button the FB login page appears.After the successful
Solution 1:
Just add below code inside updateView method.
Intent intent = newIntent(Login.this, MainActivity.class);
startActivity(intent);
So your full method will look something like below code.
privatevoidupdateView() {
Sessionsession= Session.getActiveSession();
if (session.isOpened()) {
Request.executeMeRequestAsync(session,newRequest.GraphUserCallback() {
@OverridepublicvoidonCompleted(GraphUser user, Response response) {
// TODO Auto-generated method stubfinal String t1=user.getId();
final String t2=user.getName();
// SharedPreferences myPrefs =getSharedPreferences("myprefs",MODE_WORLD_READABLE);int count=db.getme();
if(count==0)
{
map.put("uid",t1.toString());
map.put("name",t2.toString());
db.insertnewuser(map);
Intentintent=newIntent(Login.this, MainActivity.class);
startActivity(intent);
}
}
So basically it will automatically moves to next screen whenever facebook session is opened.
Solution 2:
//After successfull login it hide the facebook button
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
//after successful login into the facebook it hide the logout button
loginButton.setVisibility(View.GONE);
}
//if you want to logout after login to facebook successfully then you want to write this line inside the onSccess() method at the end//after successful login into the facebook it hide the logout button
LoginManager.getInstance().logOut();
Post a Comment for "How To Hide The Facebook Login Page Activity After Successful Login In Android?"