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

  • SEARCH
  • Home
  • 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 9215417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:12:01+00:00 2026-06-18T02:12:01+00:00

I ask about facebook android sdk Authentication error. When I rnu the program, it

  • 0

I ask about facebook android sdk Authentication error.

When I rnu the program, it appear an error is “has stopped unexpectedly. Please try again .”

debuge error is about NullPointerException problem.
(facebook-android-sdk / facebook / src / com / facebook / internal / Validate.java)

How can I solve this problem? thanks.

package com.example.fbloginau;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;


public class MainFragment extends FragmentActivity 
{

private Fragment Fragment;

public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        // Add the fragment on initial activity setup
        Fragment = new Fragment();
        getSupportFragmentManager()
        .beginTransaction()
        .add(android.R.id.content, Fragment)
        .commit();
    } 
    else 
    {
        // Or set the fragment from restored state info
        Fragment = (Fragment) getSupportFragmentManager()
        .findFragmentById(android.R.id.content);
    }
}
 }

Blockquote

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.facebook.widget.LoginButton
    android:id="@+id/authButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_marginTop="30dp"
    />

Blockquote

enter code here
  • 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-18T02:12:02+00:00Added an answer on June 18, 2026 at 2:12 am

    You can try to obtain access token via some web-service and initialize .
    you can authorize your session within activity and pass it through binder.
    Facebook facebook

    Here example.

    public class ClientService extends Service {
    
        //Facebook object to operate from service
        private Facebook facebook;
    
    ...
    
        private final ClientBinder clientBinter = new ClientBinder();
    
        /** Binder to service */
        public class ClientBinder extends Binder {
    
            public ClientService getService() {
                return ClientService.this;
            }
        }
    
        @Override
        public IBinder onBind(Intent intent) {
            return clientBinter;
        }
    
        public void setFacebook(Facebook f) {
            ClientService.this.facebook = f;
        }
    
        public boolean loggedFacebook() {
            if (facebook == null)
                return false;
            return facebook.isSessionValid();
        }
    
    }
    
    
    
    
    public class DemoActivity extends Activity{
    
            private ClientService clientService;
            private ServiceConnection clientConnection = new ServiceConnection() {
    
                public void onServiceDisconnected(ComponentName name) {
                    mBound = false;
                }
    
                public void onServiceConnected(ComponentName name, IBinder service) {
                    ClientService.ClientBinder binder = (ClientService.ClientBinder) service;
                    clientService = binder.getService();
                    mBound = true;
                    if (facebook != null)
                        if (facebook.isSessionValid())
                            clientService.setFacebook(facebook);
                }
            };
    
        @Override
        protected void onStart() {
            super.onStart();
            Intent intent = new Intent(this, ClientService.class);
            bindService(intent, clientConnection, Context.BIND_AUTO_CREATE);
        }
    
        @Override
        protected void onStop() {
            super.onStop();
            if (mBound) {
                unbindService(clientConnection);
                mBound = false;
            }
    
        }
    
    
    
    
          private void logINFacebook() {
                    if (facebook.isSessionValid())
                        return;
    
                    facebook.authorize(this,
                            getResources().getStringArray(R.array.facebookPermissions),
                            new DialogListener() {
                                public void onFacebookError(FacebookError e) {...}
    
                                public void onError(DialogError e) {...}
    
                                public void onComplete(Bundle values) {
                                    if (mBound) {
                                        clientService.setFacebook(facebook);
                                    }
    
                                    //Save to shared preferences(optional)
                                    SharedPreferences.Editor editor = prefs.edit();
                                    editor.putString(FACEBOOK_TOKEN_PREFNAME,
                                            facebook.getAccessToken());
                                    editor.putLong(FACEBOOK_EXPIRES_PREFNAME,
                                            facebook.getAccessExpires());
                                    editor.commit();
                                }
    
            @Override
            public void onActivityResult(int requestCode, int resultCode, Intent data) {
                facebook.authorizeCallback(requestCode, resultCode, data);
                super.onActivityResult(requestCode, resultCode, data);
            }
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd just like to ask about a problem I'm facing with Facebook Graph API.
Was wanting to ask about a linker error I keep getting. I installed QT
I want to ask you about profile page url of twitter/facebook. Example : twitter.com/stackoverflow
I'd like to ask about memory allocation in 64-bit ubuntu Linux. I have the
I want to ask about an edge-case scenario that I understand is very poor
i just want to ask about my html code here, i have a bit
I previously ask about converting strings to dates and formatting them.. split string based
I would like to ask about the available (free or not) Static and Dynamic
I want to ask about this function in matlab dicomread example : a =
I want to ask about strcpy. I got problem here. Here is my code:

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.