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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:31:32+00:00 2026-06-14T06:31:32+00:00

I had a Log in Button in my Android App. It works fine when

  • 0

I had a Log in Button in my Android App. It works fine when I’m logging in. But then I got this error when I’m trying to Log Out. I can’t figure it out what is causing the error.

11-12 14:44:12.358: E/AndroidRuntime(2334): FATAL EXCEPTION: main
11-12 14:44:12.358: E/AndroidRuntime(2334): android.os.NetworkOnMainThreadException
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:461)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:273)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:168)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at libcore.net.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:271)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.facebook.android.Util.openUrl(Util.java:215)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.facebook.android.Facebook.request(Facebook.java:775)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.facebook.android.Facebook.request(Facebook.java:691)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.facebook.android.Facebook.logout(Facebook.java:650)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.example.facebook.MainActivity.onClick(MainActivity.java:57)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.view.View.performClick(View.java:4084)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.view.View$PerformClick.run(View.java:16966)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.os.Handler.handleCallback(Handler.java:615)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.os.Looper.loop(Looper.java:137)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at android.app.ActivityThread.main(ActivityThread.java:4745)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at java.lang.reflect.Method.invokeNative(Native Method)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at java.lang.reflect.Method.invoke(Method.java:511)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-12 14:44:12.358: E/AndroidRuntime(2334):     at dalvik.system.NativeStart.main(Native Method)

Here is My Log Out Codes

private void updateButtonImage() {
        // TODO Auto-generated method stub
        if(fb.isSessionValid()){
            button.setImageResource(R.drawable.logout_button);
        }else{
            button.setImageResource(R.drawable.login_button);
        }
    }


    public void onClick(View arg0) {
        // TODO Auto-generated method stub
        if(fb.isSessionValid()){
            try {
                fb.logout(getApplicationContext());
                updateButtonImage();
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }else{
            fb.authorize(MainActivity.this,new String[] {"email", "publish_stream"}, new DialogListener() {

                public void onFacebookError(FacebookError e) {
                    // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(), "Facebook error", Toast.LENGTH_SHORT).show();       
                }

                public void onError(DialogError e) {
                    // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();        
                }

                public void onComplete(Bundle values) {
                    // TODO Auto-generated method stub
                    updateButtonImage();
                }

                public void onCancel() {
                    // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(), "Cancel", Toast.LENGTH_SHORT).show();   
                }
            });
        }
    }

Can anyone point what causing the error?

thanks.

  • 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-14T06:31:34+00:00Added an answer on June 14, 2026 at 6:31 am

    This exception is thrown when an application attempts to perform a networking operation on its main thread. Run your code in AsyncTask or in Thread.

    or Add below code in onCreate() method.

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this page where I am doing testing http://www.comehike.com/test_fb_connect.php The button works fine
I had try to implement the send me log feature into my apps but
I had a hard time trying to find out why my assignments where lost,
I actually previously had a much longer question but I figured this would be
Had to download Command Line Tools from Apple to get make to work, but
Had a good read through similar topics but I can't quite a) find one
Had received a module from CCAVENUE and it was working fine with Magento 1.6.2...
Had a page that was working fine. Only change I made was to add
Had a good search here but can't see anything that gets my mind in
Had a problem with the recursive conflictCheck() method. That seems fine now. I have

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.