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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:17:31+00:00 2026-06-04T20:17:31+00:00

I am currently creating an application using Phonegap 1.6.0 and Sencha Touch 1.1. Recently,

  • 0

I am currently creating an application using Phonegap 1.6.0 and Sencha Touch 1.1. Recently, when testing on a smartphone with Android 4.0.4, we discovered that the Facebook Login doesn’t quite work as expected.
We are using the Phonegap Facebook Plugin located here with patches for Cordova. What happens is that, once we try logging into Facebook on a Smartphone with Android Honeycomb or higher, the application launches a NetworkOnMainThreadException because Network operations aren’t permitted on the main thread. This exception is only thrown on Android Honeycomb or above, which is why we didn’t notice it on 2.3.3. The exception is thrown when calling FB.login() and the callback is not reached.

I have checked various threads and topics but all are extremely vague. I’m aware that I have to run the network operation in a seperate thread, but I am unsure how this should be done. Threading appears to happen in Java, but I’m not using any Java at all, so before monkeying around in code that wasn’t written by me, I’d like some help.

I will try to narrow down what part causes the exception later. Any help would be appreciated.

Error stack:

05-25 15:42:29.018: I/Web Console(3785): Cordova Facebook Connect plugin initialized successfully. at file:///android_asset/www/cdv-plugin-fb-connect.js:24
05-25 15:42:29.120: D/OpenGLRenderer(3785): Flushing caches (mode 0)
05-25 15:42:30.479: D/ConnectPlugin(3785): authorized
05-25 15:42:30.479: D/ConnectPlugin(3785): Bundle[{expires_in=5177550, access_token=censored, code=censored}]
05-25 15:42:30.503: D/AndroidRuntime(3785): Shutting down VM
05-25 15:42:30.503: W/dalvikvm(3785): threadid=1: thread exiting with uncaught exception (group=0x40a671f8)
05-25 15:42:30.511: E/AndroidRuntime(3785): FATAL EXCEPTION: main
05-25 15:42:30.511: E/AndroidRuntime(3785): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=32665, result=-1, data=Intent { (has extras) }} to activity {com.company.product/com.company.product.productActivity}: android.os.NetworkOnMainThreadException
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2980)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3023)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.ActivityThread.access$1100(ActivityThread.java:123)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1177)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.os.Looper.loop(Looper.java:137)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.ActivityThread.main(ActivityThread.java:4424)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at java.lang.reflect.Method.invokeNative(Native Method)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at java.lang.reflect.Method.invoke(Method.java:511)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at dalvik.system.NativeStart.main(Native Method)
05-25 15:42:30.511: E/AndroidRuntime(3785): Caused by: android.os.NetworkOnMainThreadException
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:664)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.io.Streams.readSingleByte(Streams.java:41)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:655)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpConnection.isStale(HttpConnection.java:256)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:71)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:460)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:432)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:270)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at com.facebook.android.Util.openUrl(Util.java:206)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at com.facebook.android.Facebook.request(Facebook.java:751)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at com.facebook.android.Facebook.request(Facebook.java:688)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at org.apache.cordova.facebook.ConnectPlugin$AuthorizeListener.onComplete(ConnectPlugin.java:271)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at com.facebook.android.Facebook.authorizeCallback(Facebook.java:433)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at org.apache.cordova.facebook.ConnectPlugin.onActivityResult(ConnectPlugin.java:196)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at org.apache.cordova.DroidGap.onActivityResult(DroidGap.java:1178)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.Activity.dispatchActivityResult(Activity.java:4649)
05-25 15:42:30.511: E/AndroidRuntime(3785):     at android.app.ActivityThread.deliverResults(ActivityThread.java:2976)
05-25 15:42:30.511: E/AndroidRuntime(3785):     ... 11 more
  • 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-04T20:17:33+00:00Added an answer on June 4, 2026 at 8:17 pm

    I managed to solve the error by putting the authentication part of ConnectPlugin.java in a separate thread. For future readers, I shall post the instructions below.

    In ConnectPlugin.java, replace:

    try {
        JSONObject o = new JSONObject(this.fba.facebook.request("/me"));
        this.fba.userId = o.getString("id");
        this.fba.success(getResponse(), this.fba.callbackId);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    

    with the following code:

    Thread t = new Thread(new Runnable() {
        public void run() {
            try {
                JSONObject o = new JSONObject(fba.facebook.request("/me"));
                fba.userId = o.getString("id");
                fba.success(getResponse(), fba.callbackId);
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    t.start();
    

    That should fix the NetworkOnMainThreadException.

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

Sidebar

Related Questions

I'm currently building an application using Sencha Touch. We have a certain Carousel on
I am currently creating an application (iPhone/iPad/Android) that uses a map to display houses
I am new on android development, and i was currently creating an application using
Here's something that has been bugging me... I am currently creating an application for
I'm currently creating an MVC application that will likely to expand to include a
I am currently in the process of creating an application that records current location
I'm currently creating an application using the MVC3 framework. I understand how to use
I'm currently creating a WPF application, using C# and XAML in Visual Studios 2010.
I am currently creating a web application that will be deployed in an intranet
I'm currently creating a small silverlight application for testing, to see if it can

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.