How do I check if the user has already accepted the facebook login terms?

0

After the first login, I log out, and try to log in again, but the hash key error, but if I delete the application from my facebook account and log in again right. How do I resolve this?

public class LoginFacebook extends Fragment {

    private LoginButton loginButton;
    private CallbackManager callbackManager;
    private AccessTokenTracker accessTokenTracker;
    private AccessToken accessToken;
    private MainAct mainAct;

    @Override
    public View onCreateView(
            final LayoutInflater inflater,
            final ViewGroup container,
            Bundle savedInstanceState) {
        FacebookSdk.sdkInitialize(getContext());

        callbackManager = CallbackManager.Factory.create();
        final View view = inflater.inflate(R.layout.loginfacebook, container, false);

//


       loginButton = (LoginButton)view.findViewById(R.id.loginfacebook);
        loginButton.setFragment(this);
        loginButton.setReadPermissions(Arrays.asList("email"));
        loginButton.setReadPermissions(Arrays.asList("public_profile"));



        // Callback registration
        loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                AlertDialog.Builder dlg = new AlertDialog.Builder(getContext());
                dlg.setMessage("deu"+loginResult.getAccessToken().getUserId());
                dlg.setNeutralButton("ok",null);
                dlg.show();


            }


            @Override
            public void onCancel() {
                AlertDialog.Builder dlg = new AlertDialog.Builder(getContext());
                dlg.setMessage("cancelou");
                dlg.setNeutralButton("ok",null);
                dlg.show();

            }

            @Override
            public void onError(FacebookException exception) {
                AlertDialog.Builder dlg = new AlertDialog.Builder(getContext());
                dlg.setMessage("deu erro");
                dlg.setNeutralButton("ok",null);
                dlg.show();

            }
        });


        accessTokenTracker = new AccessTokenTracker() {
            @Override
            protected void onCurrentAccessTokenChanged(
                    AccessToken oldAccessToken,
                    AccessToken currentAccessToken) {
                // Set the access token using
                // currentAccessToken when it's loaded or set.
            }
        };






        return view;

    }
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
        if (isLoggedIn()) {
            Intent intent = new Intent(getContext(), Afterlogin.class);
            startActivity(intent);
        }

    }
    public boolean isLoggedIn() {
        AccessToken accessToken = AccessToken.getCurrentAccessToken();
        return accessToken != null;
    }



}
    
asked by anonymous 05.09.2016 / 01:13

0 answers