开发者

How to display skip button for facebook Single Sign on?

I am using this method to allow the user to sign on to facebook at the beginning of the application, If they want.

package com.greatap;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.facebook.android.*;
import com.facebook.android.Facebook.*;

public class MyGreatActivity extends Activity {

Facebook facebook = new Facebook("YOUR_APP_ID");

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    facebook.authorize(this, new DialogListener() {
        @Override
        public void onComplete(开发者_如何学编程Bundle values) {}

        @Override
        public void onFacebookError(FacebookError error) {}

        @Override
        public void onError(DialogError e) {}

        @Override
        public void onCancel() {}
    });
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    facebook.authorizeCallback(requestCode, resultCode, data);
}

}

If they dont want to then the can just press skip to continue using the app without signing in. Ive seen this in many applications. I dont see any instructions on the developer's page for facebook to implement this. Some help would be greatly appreciated!


Ok Consider you created a dialog with two buttons "Log in" and "Skip"

Move this block of code:

    facebook.authorize(this, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {}

        @Override
        public void onFacebookError(FacebookError error) {}

        @Override
        public void onError(DialogError e) {}

        @Override
        public void onCancel() {}
    });

to the conditional:

if(userPressedLoginAndNotSkip){
        facebook.authorize(this, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {}

        @Override
        public void onFacebookError(FacebookError error) {}

        @Override
        public void onError(DialogError e) {}

        @Override
        public void onCancel() {}
    });
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜