Login to Facebook with the right to read and publish to android facebook SDK 4.8.0

Integrated Facebook login in my Android app.
I have two requirements in my application
1) Obtaining a registered user email id
2) Send the feed to the Facebook user on the wall about installing the application and the link

I can get emails using read permissions

private void fbLogin() { LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList( "public_profile", "user_birthday", "email" ) ); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { SharedPreferences.Editor editor = facebookPreferences.edit(); AccessToken accessToken = loginResult.getAccessToken(); if (accessToken != null) { fbProfile(); } } } 

I can publish a feed using publish permissions

 private void fbLogin() { LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList( "publish_actions" ) ); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { SharedPreferences.Editor editor = facebookPreferences.edit(); AccessToken accessToken = loginResult.getAccessToken(); if (accessToken != null) { fbPostAFeed(); } } } 

No re-entry to change the resolution.
But my requirement is to get an email id and submit the feed to Facebook. I know that login can be associated with read permissions or publishing permissions. I searched about this, I found that one thing is the session, but, Facebook doc says: the session class is no longer available in the latest version of the SDK Then how can I do it. This is their way of doing it. Thanks in advance.

+7
android facebook
source share
1 answer

You need to add some permissions and add below the fr code for channel exchange, below the code also contains images. You can customize it according to your needs.

 List<String> permissionNeeds = Arrays.asList("publish_actions"); manager = LoginManager.getInstance(); manager.logInWithPublishPermissions(this, permissionNeeds); manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { publishImage(); } @Override public void onCancel() { System.out.println("onCancel"); } @Override public void onError(FacebookException exception) { System.out.println("onError"); } }); } private void publishImage() { Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); //You need to get bitmap from any source. SharePhoto photo = new SharePhoto.Builder().setBitmap(image) .setCaption("Welcome To Facebook Photo Sharing on steroids!") .build(); SharePhotoContent content = new SharePhotoContent.Builder().addPhoto( photo).build(); ShareApi.share(content, null); Toast.makeText(this, "Succsesfully posted on your wall", Toast.LENGTH_LONG).show(); } 
0
source share

All Articles