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 7063417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:42:40+00:00 2026-05-28T04:42:40+00:00

I am trying to integrate facebook with android mobile, all i need to do

  • 0

I am trying to integrate facebook with android mobile, all i need to do is to take some text from my application and put it as status on Facebook, i have tried facebook_sdk for the purpose, when i saw the debugging mode, the application is terminating at the line facebook.authorize(), though there is full internet connectivity in menifest… below is my code:
Thanks in advance

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    button1 = (Button)findViewById(R.id.Button1);
    button2 = (Button)findViewById(R.id.Button2);
    tv1 = (TextView)findViewById(R.id.TextView1);
    et1 = (EditText)findViewById(R.id.EditText1);
    button1.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            b1Click();
        }

    });
    button2.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v) {
            b2Click();
        }

    });
}
private void saveFBToken(String token, long tokenExpires){
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    prefs.edit().putString("FacebookToken", token).commit();
}

private void fbAuthAndPost(final String message){

    facebook.authorize(this, new String[]{"publish_stream"},new   DialogListener() {

        @Override
        public void onComplete(Bundle values) {
            Log.d(this.getClass().getName(),"Facebook.authorize Complete: ");
            saveFBToken(facebook.getAccessToken(), facebook.getAccessExpires());
            updateStatus(values.getString(Facebook.TOKEN), message);
        }

        @Override
        public void onFacebookError(FacebookError error) {
            Log.d(this.getClass().getName(),"Facebook.authorize Error: "+error.toString());
        }

        @Override
        public void onError(DialogError e) {
            Log.d(this.getClass().getName(),"Facebook.authorize DialogError: "+e.toString());
        }

        @Override
        public void onCancel() {
            Log.d(this.getClass().getName(),"Facebook authorization canceled");
        }
    });
}

@Override
protected void onActivityResult(int requestCode, int resultCode,Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode){
    case Facebook.FORCE_DIALOG_AUTH:
        facebook.authorizeCallback(requestCode, resultCode, data);
    }
}

private void b1Click(){

    mAuthAttempts = 0;

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mFacebookToken = prefs.getString("FacebookToken", "");

    if(mFacebookToken.equals("")){
        fbAuthAndPost(et1.getText().toString());
    }else{
        updateStatus(mFacebookToken,et1.getText().toString());
    }
}

private void b2Click(){
    mAuthAttempts = 0;
    updateStatus(facebook.TOKEN,et1.getText().toString());
}

public void updateStatus(String accessToken, String message){
    try {         
        Bundle bundle = new Bundle();
        bundle.putString("message", message);         
        bundle.putString(Facebook.TOKEN,accessToken);         
        String response = facebook.request("me/feed",bundle,"POST");         
        Log.d("UPDATE RESPONSE",""+response);
        showToast("Update process complete. Respose:"+response);
        if(response.indexOf("OAuthException") > -1){
            if(mAuthAttempts==0){
                mAuthAttempts++;
                fbAuthAndPost(message);
            }else{
                showToast("OAuthException:");
            }
        }
    } catch (MalformedURLException e) {         
        Log.e("MALFORMED URL",""+e.getMessage());
        showToast("MalformedURLException:"+e.getMessage());
    } catch (IOException e) {         
        Log.e("IOEX",""+e.getMessage());
        showToast("IOException:"+e.getMessage());
    }

    String s = facebook.getAccessToken()+"\n";
    s += String.valueOf(facebook.getAccessExpires())+"\n";
    s += "Now:"+String.valueOf(System.currentTimeMillis())+"\n";
    tv1.setText(s);
} 
private void showToast(String message){
    Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
}
  • 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-05-28T04:42:40+00:00Added an answer on May 28, 2026 at 4:42 am

    I would appreciate some details on the error you receive before the app crashes Like Usama said the logcat would be great. I can’t see where do you initialize the variable facebook = new Facebook(APP_ID);. Make sure that you have also all the activities facebook is using in your manifest. Finally I let you this:
    https://github.com/facebook/facebook-android-sdk/blob/master/examples/simple/src/com/facebook/android/Example.java

    I hope that some of this helps.

    << When you try to log in to the Facebook page, you receive a Token if thee user and the password were correct, this means that the application has a valid user loged in to the facebook servers. The SessionStore class saves that token in your shared preferences. So then you can use the Token to connect to facebook again later without asking the password to the user. You can do this only if the session hasn’t expired.
    About the error:
    “This exception is thrown by the resource APIs when a requested resource can not be found.”

    I did the facebook integration a long time ago, and for a company so I can’t pass you the code because I don’t have it. Look at this post maybe it helps. http://www.jiahaoliuliu.com/2011/05/android-runtime-error.html

    I’ll look around to see if I find something more explicit.

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

Sidebar

Related Questions

I am trying to integrate facebook in my iphone application. after logged in from
I'm trying to integrate some photo related functionality with my site and facebook. I
I am trying to make an application which integrates facebook and twitter. I have
I am trying to integrate facebook connect with my cakephp application. i am not
I am trying to integrate one of my websites with facebook connect. I have
I'm trying to write some javascript functions to integrate with the Facebook stream. However
I'm trying to integrate the Facebook Android SDK in my app, but I can't
I'm trying to retrieve in my android app(in which I have facebook integrated )
I am trying to develop a Facebook application for Android. I am unable to
I'm trying to integrate Facebook into a site I'm developing, I have created a

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.