简体   繁体   中英

Unable to Login to facebook using new Android sdk?

I am using new Facebook Android Sdk in my Application, I have created App ID in developer page and used the code below

code:

 private   List<String> PERMISSIONS = Arrays.asList("user_photos","email");


     public void loginToFacebook(){

            Session.openActiveSession(getParent(), true, new Session.StatusCallback() {


            @Override
            public void call(final Session session, SessionState state,Exception exception) {
                // TODO Auto-generated method stub


                 Log.e("session",""+session.isOpened());

//               dialog.dismiss();

                   if (session.isOpened()) {


/

                    List<String> permissions = session.getPermissions();

                     Log.e("current permissions",""+permissions);

                     if (!isSubsetOf(PERMISSIONS, permissions)) {

                     Log.e("if permissions=======",""+permissions);

                     Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(getParent(), PERMISSIONS);

                     session.requestNewReadPermissions(newPermissionsRequest);

                     return;
                     }

                     // make request to the /me API
                     Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                        @Override
                        public void onCompleted(GraphUser user,Response response) {
                            // TODO Auto-generated method stub

                            Log.e("oncompletedddddddddddd","if open user");

                               if (user != null) {

                                Log.e("session","if open user");



                                      Intent intent=new Intent(getParent(),FacebookPostActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                      View view = CheckInTab.group.getLocalActivityManager().startActivity("q",intent).getDecorView();  
                                            // Again, replace the view  
                                      CheckInTab.group.replaceView(view);

//                                    publishFeedDialog(strFacebookId);

                                 }catch(Exception e){e.printStackTrace();}


                                          }

                                // Check for publish permissions    



                        }


                     });
                   }



        }
           });

       }

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

 private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
             for (String string : subset) {
                 if (!superset.contains(string)) {
                     return false;
                 }
             }
             return true;
         }

I am getting the dialog below continuously after my Login screen, I also observed that even we click Cancel or Cross, again the same dialog is appearing. 在此输入图像描述

Please suggest for the solution.

You can remove the app from the list of approved apps from Facebook itself. From your browser:

  1. Click the downward pointing arrow in the upper right hand corner of the top bar.
  2. Select "Settings"
  3. On the left, select "Apps"
  4. Find the app name in the list (you may have to click "Show all apps (#)" at the bottom of the list" and select the "x" to the right of the app name.
  5. Agree to remove the app permissions.

From the Facebook app on your phone:

  1. Swipe all the way to the right (the three horizontal bars icon)
  2. Scroll down to the "HELP & SETTINGS" section
  3. Select "Account Settings"
  4. Scroll down and select the "Apps" item
  5. Find and select the app in one of the "Sharing with * " sections
  6. Touch the "Remove [app name]" button at the bottom

After you've removed the app permissions from Facebook, you should be able to run your app again and it will allow you to login.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM