Facebook authentication via android app

codeomnitrix

I am new to android. I am developing an application which requires facebook login to proceed. So for this I have followed this tutorial - https://developers.facebook.com/docs/android/getting-started

EDIT: Using UILifecycleHelper, same thing happen, once user authenticates the application application is closed.

private Session.StatusCallback callback = new Session.StatusCallback() {
        @Override
        public void call(Session session, SessionState state, Exception exception) {
            if (session.isOpened()) {
                Log.w("Vinit", "Session started");
              // make request to the /me API
              Request.newMeRequest(session, new Request.GraphUserCallback() {

                // callback after Graph API response with user object
                @Override
                public void onCompleted(GraphUser user, Response response) {
                  if (user != null) {
                    TextView t = (TextView) findViewById(R.id.textView1);
                    t.setText("User: " + user.getFirstName());

                  }
                }
              }).executeAsync();
            }
        }
    };

    private FacebookDialog.Callback dialogCallback = new FacebookDialog.Callback() {
        @Override
        public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
            Log.d("HelloFacebook", String.format("Error: %s", error.toString()));
        }

        @Override
        public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
            Log.d("HelloFacebook", "Success!");
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);            
        if(new LoginChecker(this).isRegistered()){
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
        }else{
            setContentView(R.layout.activity_login);            
            LoginButton loginButton = (LoginButton) findViewById(R.id.loginButton1);
            thisActivity = this;
            loginButton.setOnClickListener(new OnClickListener() {                              
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub                  
                    uiHelper = new UiLifecycleHelper(thisActivity, callback);
                }
            });

        }
    }
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          Log.w("Vinit", "On Activity Result function");
          uiHelper.onActivityResult(requestCode, resultCode, data, dialogCallback);
    }
klimat
  1. Use UiLifecycleHelper https://developers.facebook.com/docs/reference/android/current/class/UiLifecycleHelper to be sure that your activity/fragment handle processing from facebook component in proper way.
  2. Check Facebook Session object. Does app call instructions inside session.IsOpened()? Try debug your code to see state of the Facebook Session.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Build Android Studio app via command line

分類Dev

Design for Facebook authentication in an iOS app that also accesses a secured web service

分類Dev

Open Facebook page from Android app?

分類Dev

HTTP authentication logout via PHP

分類Dev

HTTP authentication logout via PHP

分類Dev

iOS: Login to Facebook through app

分類Dev

API authentication from a facebook messenger bot conversation

分類Dev

How to use Facebook authentication in Laravel 5.3

分類Dev

Custom web app authentication with WildFly

分類Dev

View showing up with delay after Facebook Authentication

分類Dev

Microsft Owin Facebook authentication is not working in MVC application

分類Dev

Android Firebase phone authentication INVALID_APP_CREDENTIAL:App validation failed

分類Dev

Firebase Rules with facebook Authentication and Unique IDs

分類Dev

In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

分類Dev

How to request additional claims with Facebook authentication

分類Dev

Facebook APP用户ID

分類Dev

Can't get my android app use facebook although after putting my hash keys

分類Dev

Error while using facebook app invite for android

分類Dev

Fetch Facebook friends information like email id and phone number from android app version 4.4

分類Dev

Mobile app Web API authentication

分類Dev

Android app custom web service authentication using HttpPost does not stick

分類Dev

Apps are updating status via facebook android sdk 3.17 but not when using Facebook's official app (#404)

分類Dev

can people see Facebook IOS app on their facebook?

分類Dev

Retrieving the user name and email id from Facebook into my android app

分類Dev

Facebook read_mailbox permission in Android App

分類Dev

Mobile App Authentication

分類Dev

How to access datahug API via HTTP Authentication?

分類Dev

New User vs Old Firebase Facebook Authentication

分類Dev

Android: Can't receive images via ACTION_SEND from FaceBook

Related 関連記事

  1. 1

    Build Android Studio app via command line

  2. 2

    Design for Facebook authentication in an iOS app that also accesses a secured web service

  3. 3

    Open Facebook page from Android app?

  4. 4

    HTTP authentication logout via PHP

  5. 5

    HTTP authentication logout via PHP

  6. 6

    iOS: Login to Facebook through app

  7. 7

    API authentication from a facebook messenger bot conversation

  8. 8

    How to use Facebook authentication in Laravel 5.3

  9. 9

    Custom web app authentication with WildFly

  10. 10

    View showing up with delay after Facebook Authentication

  11. 11

    Microsft Owin Facebook authentication is not working in MVC application

  12. 12

    Android Firebase phone authentication INVALID_APP_CREDENTIAL:App validation failed

  13. 13

    Firebase Rules with facebook Authentication and Unique IDs

  14. 14

    In-app purchases (IAP) in android with BOTH Google and Facebook authentication?

  15. 15

    How to request additional claims with Facebook authentication

  16. 16

    Facebook APP用户ID

  17. 17

    Can't get my android app use facebook although after putting my hash keys

  18. 18

    Error while using facebook app invite for android

  19. 19

    Fetch Facebook friends information like email id and phone number from android app version 4.4

  20. 20

    Mobile app Web API authentication

  21. 21

    Android app custom web service authentication using HttpPost does not stick

  22. 22

    Apps are updating status via facebook android sdk 3.17 but not when using Facebook's official app (#404)

  23. 23

    can people see Facebook IOS app on their facebook?

  24. 24

    Retrieving the user name and email id from Facebook into my android app

  25. 25

    Facebook read_mailbox permission in Android App

  26. 26

    Mobile App Authentication

  27. 27

    How to access datahug API via HTTP Authentication?

  28. 28

    New User vs Old Firebase Facebook Authentication

  29. 29

    Android: Can't receive images via ACTION_SEND from FaceBook

ホットタグ

アーカイブ