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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:25:11+00:00 2026-06-17T04:25:11+00:00

I am trying to integrate an android app with the the new facebook 3.0

  • 0

I am trying to integrate an android app with the the new facebook 3.0 api, but I get this exception:

java.lang.RuntimeException: Unable to resume activity
{dk.imu.konnekt/com.facebook.LoginActivity}:
com.facebook.FacebookException: Cannot call LoginActivity with a null
calling package. This can occur if the launchMode of the caller is
singleInstance.

I have search for this error but no one else seems to have had any troble with it. I guess it is because I am using a TabHost and TabsGroupActivities for each tab. But I have no clue on how to solve it.

I have added the relevant code here:

public class MainTabActivity extends TabActivity {    
    public void onCreate(Bundle savedInstanteState){
        super.onCreate(savedInstanteState);
        setContentView(R.layout.tab_layout);
        TabHost tabHost = getTabHost();

        View shareTab = getLayoutInflater().inflate(R.layout.share_tab, null);
        tabHost.addTab(tabHost.newTabSpec("Share").setIndicator(shareTab)
        .setContent(new Intent(MainTabActivity.this, ShareGroupActivity.class)));

        ...
    }
}

–

public class ShareGroupActivity extends TabsGroupActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        startChildActivity("ShareActivity", new Intent(this, ShareActivity.class));
    }
}

–

public class ShareActivity extends BaseActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.share);

        testFacebookConnection();
    }

    public void testFacebookConnection(){
        Session session = new Session(this);
        Session.setActiveSession(session);
        SessionState state = session.getState();

        Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

        Session.StatusCallback statusCallback = 
            new Session.StatusCallback() {
            @Override
            public void call(Session session, SessionState state, Exception exception) {
                Toast.makeText(ShareActivity.this, "Facebook session status changed", Toast.LENGTH_SHORT).show(); 
            }
        };

        if (!session.isOpened() && !session.isClosed() && session.getState() != SessionState.OPENING) {
            OpenRequest open = new OpenRequest(this).setCallback(statusCallback);
            List<String> permission = new ArrayList<String>();
            permission.add("publish_actions");
            open.setPermissions(permission);
            session.openForPublish(open);
        } else {
            Session.openActiveSession(this, true, statusCallback);
        }
    }   

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

Any clue on how to solve it?

Update 1 stack trace:

FATAL EXCEPTION: main java.lang.RuntimeException: Unable to resume
activity {dk.imu.konnekt/com.facebook.LoginActivity}:
com.facebook.FacebookException: Cannot call LoginActivity with a null
calling package. This can occur if the launchMode of the caller is
singleInstance. at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:2812)
at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2851)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2234)
at android.app.ActivityThread.access$600(ActivityThread.java:139) at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
at android.os.Handler.dispatchMessage(Handler.java:99)
android.os.Looper.loop(Looper.java:154) at
android.app.ActivityThread.main(ActivityThread.java:4945) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:511) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at
dalvik.system.NativeStart.main(Native Method) Caused by:
com.facebook.FacebookException: Cannot call LoginActivity with a null
calling package. This can occur if the launchMode of the caller is
singleInstance. at
com.facebook.LoginActivity.onResume(LoginActivity.java:110) at
android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1236)
at android.app.Activity.performResume(Activity.java:4613) at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:2796)
… 12 more

Update 2:
I looked through the code and found the implementation of startChildActivity:

public void startChildActivity(String Id, Intent intent) {     
   Window window = getLocalActivityManager().startActivity(Id,intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
   if (window != null) {
       mIdList.add(Id);
       setContentView(window.getDecorView()); 
   }    
}

It uses the flag FLAG_ACTIVITY_CLEAR_TOP. I tried to remove it, but no change in the outcome.

Update 3:

https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/LoginActivity.java

The Facebook code uses

callingPackage = getCallingPackage();

and

if (callingPackage == null) {
       throw new FacebookException(NULL_CALLING_PKG_ERROR_MSG);
}

http://developer.android.com/reference/android/app/Activity.html#getCallingPackage()

This method has a note:

If the calling activity is not expecting a result (that is it did not
use the startActivityForResult(Intent, int) form that includes a
request code), then the calling package will be null.

In the method startChildActivity I use the getLocalActivityManager().startActivity, in TabsGroupActivity that extends ActivityGroup, to handle tab activities.
http://developer.android.com/reference/android/app/LocalActivityManager.html#startActivity(java.lang.String, android.content.Intent)

This method does not what the notes says. It does not expect a result and does not use the startActivityForResult method. The method also ensures something similar to singleinstance launchmode.
How should I change this method implementation, so it can work with facebook?

  • 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-17T04:25:13+00:00Added an answer on June 17, 2026 at 4:25 am

    After lots of searching I figured out that there don’t seems to be a way to startActivityForResult with LocalActivityManager used in the tabs.

    So I ended up accepting that it will need an activity filling the entire screen. The activity is only shown a second or so with good network connection – I have made it with a republish option on errors also..

    Start publish activity:

    Intent intent = new Intent(this, FacebookShareActivity.class);
    intent.putExtra(Constants.FACEBOOK_MESSAGE, shareMessage.getMessage());
    startActivityForResult(intent, 1);
    

    Facebook share activity code – publishing to users wall:

    public class FacebookShareActivity extends Activity {
        String message;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.facebook_publishing);
    
            message = getIntent().getExtras().getString(Constants.FACEBOOK_MESSAGE);
            createFacebookConnection();
        }
    
        public void republishButton_Click(View view){
            setVisibilityForRepublishButton(false);
            createFacebookConnection();
        }
    
        public void createFacebookConnection() {
            Session session = new Session(this);
            Session.setActiveSession(session);
    
            Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
    
            Session.StatusCallback statusCallback = new Session.StatusCallback() {
                @Override
                public void call(Session session, SessionState state, Exception exception) {
                    String message = "Facebook session status changed - " + session.getState() + " - Exception: " + exception;
                    //Toast.makeText(FacebookShareActivity.this, message, Toast.LENGTH_SHORT).show();
                    Log.w("Facebook test", message);
    
                    if (session.isOpened() || session.getPermissions().contains("publish_actions")) {
                        publishToWall();
                    } else if (session.isOpened()) {
                        OpenRequest open = new OpenRequest(FacebookShareActivity.this).setCallback(this);
                        List<String> permission = new ArrayList<String>();
                        permission.add("publish_actions");
                        open.setPermissions(permission);
                        Log.w("Facebook test", "Open for publish");
                        session.openForPublish(open);
                    }
                }
            };
    
            if (!session.isOpened() && !session.isClosed() && session.getState() != SessionState.OPENING) {
                session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
            } else {
                Log.w("Facebook test", "Open active session");
                Session.openActiveSession(this, true, statusCallback);
            }
        }
    
        private void setVisibilityForRepublishButton(Boolean visible) {
            ((Button) findViewById(R.id.republishButton)).setVisibility(visible ? View.VISIBLE : View.GONE);
        }
    
        @Override
        public void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);
            Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
            //Toast.makeText(FacebookShareActivity.this, "onActivityResult", Toast.LENGTH_SHORT).show();
        }
    
        void publishToWall() {
            Session session = Session.getActiveSession();
    
            Bundle postParams = new Bundle();
            postParams.putString("message", message);
    
            final Context context = this;
            Request.Callback callback = new Request.Callback() {
                public void onCompleted(Response response) {
                    FacebookRequestError error = response.getError();
                    if (error != null) {
                        setVisibilityForRepublishButton(true);
                        Toast.makeText(context, error.getErrorMessage(), Toast.LENGTH_SHORT).show();
                    } else {
                        JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
                        String postId = null;
                        try {
                            postId = graphResponse.getString("id");
                        } catch (JSONException e) {
                            setVisibilityForRepublishButton(true);
                            Log.i("Facebook error", "JSON error " + e.getMessage());
                        }
                        //Toast.makeText(context, postId, Toast.LENGTH_LONG).show();
                        finish();
                    }
                }
            };
    
            Request request = new Request(Session.getActiveSession(), "me/feed", postParams, HttpMethod.POST, callback);
    
            RequestAsyncTask task = new RequestAsyncTask(request);
            task.execute();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate the Facebook Android SDK in my app, but I can't
I'm trying to integrate Facebook into my Android Java app, what I want it
Hi I'm trying to integrate MySpace with my Android app. As I'm new to
I am trying to integrate ZBar in my Android app but I cannot build
I am trying to integrate Facebook to my Android app for social post. I
I'm trying to integrate Android Market in-app purchases into my app, but unfortunately coming
I'm trying to integrate abs into my app, but I keep getting this error
I am trying to integrate Facebook ** into my android app. I want to
I'm trying to integrate facebook login on my android app. I found a lot
I am trying to integrate Facebook with my app. I read this on developers.facebook.com

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.