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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:08:39+00:00 2026-06-12T10:08:39+00:00

I’m using Android facebook SDK for post on facebook wall.I have used following code

  • 0

I’m using Android facebook SDK for post on facebook wall.I have used following code for wall post but every time through exception android.os.NetworkOnMainThreadException

public void postToWall(String message) {
        Bundle parameters = new Bundle();
        parameters.putString("message", message);
        parameters.putString("description", "topic share");
        try {
            facebook.request("me");//Error here
            String response = facebook.request("me/feed", parameters, "POST");
            Log.d("Tests", "got response: " + response);
            if (response == null || response.equals("")
                    || response.equals("false")) {
                showToast("Blank response.");
            } else {
                showToast("Message posted to your facebook wall!");
            }
            finish();
        } catch (Exception e) {
            showToast("Failed to post to wall!");
            e.printStackTrace();
            finish();
        }
    }

Logcat

android.os.NetworkOnMainThreadException
W/System.err( 1048):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
W/System.err( 1048):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
W/System.err( 1048):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
W/System.err( 1048):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
W/System.err( 1048):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
W/System.err( 1048):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
W/System.err( 1048):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
W/System.err( 1048):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
W/System.err( 1048):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
W/System.err( 1048):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
W/System.err( 1048):    at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461)
W/System.err( 1048):    at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)
W/System.err( 1048):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
W/System.err( 1048):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
W/System.err( 1048):    at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
W/System.err( 1048):    at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
W/System.err( 1048):    at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
W/System.err( 1048):    at com.facebook.android.Util.openUrl(Util.java:215)
W/System.err( 1048):    at com.facebook.android.Facebook.request(Facebook.java:776)
W/System.err( 1048):    at com.facebook.android.Facebook.request(Facebook.java:713)
W/System.err( 1048):    at com.example.share.Share.postToWall(Share.java:86)
W/System.err( 1048):    at com.example.share.Share.share(Share.java:72)
W/System.err( 1048):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1048):    at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1048):    at android.view.View$1.onClick(View.java:3586)
W/System.err( 1048):    at android.view.View.performClick(View.java:4084)
W/System.err( 1048):    at android.view.View$PerformClick.run(View.java:16966)
W/System.err( 1048):    at android.os.Handler.handleCallback(Handler.java:615)
W/System.err( 1048):    at android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err( 1048):    at android.os.Looper.loop(Looper.java:137)
W/System.err( 1048):    at android.app.ActivityThread.main(ActivityThread.java:4745)
W/System.err( 1048):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 1048):    at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err( 1048):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
W/System.err( 1048):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
W/System.err( 1048):    at dalvik.system.NativeStart.main(Native Method)
W/WindowManager(  145): Failure taking screenshot for (246x410) to layer 21010
I/Choreographer( 1048): Skipped 40 frames!  The application may be doing too much work on its main thread.
D/dalvikvm(  226): GC_CONCURRENT freed 384K, 7% free 8535K/9095K, paused 20ms+4ms, total 52ms
  • 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-12T10:08:40+00:00Added an answer on June 12, 2026 at 10:08 am

    You cannot perform network IO on the UI thread on Honeycombe or later.
    Technically it is possible on earlier versions of Android, but is a
    really bad idea as it will cause your app to stop responding, and can
    result in the OS killing your app for being badly behaved. You’ll need
    to run a background process or use AsyncTask to perform your network
    transaction on a background thread.

    Edit : Another Idea but it is not good . It is Bad Practice to use it but some people use it.

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy); 
    

    Add above code in your activity class.

    I personally Prefer the first option use thread or AsyncTask .

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

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.