Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:35:34+00:00 2026-06-07T10:35:34+00:00

I need to implement facebook’s share feature into my android app. My scenario is

  • 0

I need to implement facebook’s share feature into my android app. My scenario is that I have to be able to use the facebook object created in the launch screen among all the other activities. I have already checked into the related questions in SO & found below mentioned links. Now I am guessing, which one of them is the ideal way to implement. Please let me know your views on these methods or If you have your own approach please let me know.

Sharing a global facebook object across Android activities

Facebook android: passing facebook object between activities

Android: Passing a Facebook session across activities

Facebook wall post from multiple Activities
In the answers mentioned above

First Solution deals with creating the facebook object within application context and sharing across the application:

public class GlobalVars extends Application {

public static final String APP_ID = "123456789";    
public Facebook facebook = new Facebook(APP_ID);

}

Second Solution states the use of sharedprefernces. after creating a valid facebook session, it is stored in sharedpreferences and restored back in each activity when required.

SharedPreferences prefs = getApplicationContext().getSharedPreferences("facebook",MODE_PRIVATE);
String access_token = prefs.getString("access_token", null);
long expires = prefs.getLong("access_expires", 0);
if(access_token != null) {
facebook.setAccessToken(access_token);
}
if(expires != 0) {
facebook.setAccessExpires(expires);
}

Third Solution states the use of parcelable implementation.

public void writeToParcel(Parcel out, int flags) {
out.writeInt(mData);

}

Fourth solution is trying to create a class containing static Facebook object and trying to use the same from all activities.

Class Utiltiy {
public static Facebook mFacebook;

public static void initialize() {
   mFacebook = new Facebook(app_id);
}
}

Utility.mFacebook.request(....).

Thanks for going through whole post. Please suggest a suitable approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:35:37+00:00Added an answer on June 7, 2026 at 10:35 am

    There is one more approach with storing facebook credentials in Android Account Manager.
    If user installed facebook app and already logged in you can get his credentials from Account Manager. And this method gives users a central point (Settings -> Accounts) to define its credentials. From there you can customize them or even delete them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app should implement login with facebook but I have noticed that every time
I need to implement facebook-connect to a website where users already might have their
really need your help with log-in-with-facebook feature I'm trying to implement on my website.
I have a flex android mobile application and I want to implement facebook's SSO.
I have used facebook application for one of my android application. But i need
i have developed a php based app for facebook. now i need to push
I wanna implement Facebook connect into my application on android. But i am not
I have an Facebook enabled, iOS 5 app that uses a storyboard and segue
I am trying to implement something similar to the share feature on Dropbox that
I need to implement facebook connect in Pyrocms based site.The user module is working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.