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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:04:49+00:00 2026-06-13T11:04:49+00:00

I want to send a simple http notification after user hit DONE. I use

  • 0

I want to send a simple http notification after user hit DONE. I use AsyncTask for network operations and i dont understand why application still crash with this exception android.os.NetworkOnMainThreadException.

private void buttonPressed() {
    EditText editTextLogin = (EditText) findViewById(R.id.editTextPassword);

    editTextLogin.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView arg0, int actionId, KeyEvent event) {
            try{
                MyAsync test = new MyAsync(activity);
                test.execute("http://google.com");
            }catch (Exception e) {
                // TODO: handle exception
                Log.e("log_tag", "Error in http connection "+e.toString());
            }
            return true;
        }
    });
}

I am not allowed to run this task at that line ?

Here is the class

class MyAsync extends AsyncTask<String, Void, String[]>{
    private final Activity activity;

    public MyAsync(Activity anActivity){
        activity = anActivity; //just in case i will need it later
    }

    @Override
    protected String[] doInBackground(String... args) {
        // TODO Auto-generated method stub
        Document doc = Jsoup.connect(args[0]).get();
        //do something with this document as soon this error android.os.NetworkOnMainThreadException wont rise again
        return new String[0];
    }

    @Override
    // Once the image is downloaded, associates it to the imageView
    protected void onPostExecute(String[] result) {
        Log.e('MyAsync','Finally i got it to work');
    }
}

Error Logcat:-

10-26 23:20:16.729: E/AndroidRuntime(1029): FATAL EXCEPTION: AsyncTask #1
10-26 23:20:16.729: E/AndroidRuntime(1029): java.lang.RuntimeException: An error occured while executing doInBackground()
10-26 23:20:16.729: E/AndroidRuntime(1029):     at android.os.AsyncTask$3.done(AsyncTask.java:278)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.lang.Thread.run(Thread.java:856)
10-26 23:20:16.729: E/AndroidRuntime(1029): Caused by: java.lang.VerifyError: org/jivesoftware/smack/sasl/SASLMechanism
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.lang.reflect.Constructor.constructNative(Native Method)
10-26 23:20:16.729: E/AndroidRuntime(1029):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
  • 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-13T11:04:50+00:00Added an answer on June 13, 2026 at 11:04 am

    You are using a version of Smack that is incompatible with Android, apparently. IIRC, there is an aSmack library that you should be using.

    You can tell that this is a problem with Smack because of the exception:

    10-26 23:20:16.729: E/AndroidRuntime(1029): Caused by: java.lang.VerifyError: org/jivesoftware/smack/sasl/SASLMechanism
    

    org.jivesoftware.smack is the Smack library.

    You will also note that this is not android.os.NetworkOnMainThreadException, but java.lang.VerifyError.

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

Sidebar

Related Questions

I want to be able to send a simple http post from my firefox
Hello Sir i want send list of data to php server i use following
I am using this http://github.com/professionalnerd/simple-private-messages plugin in rails and I am on a user
I want to use ms sql 2005 to send email reminders to my customers.
I am trying to send a simple HTTP request like this: var client =
Greetings, I want to write a script that handles simple http requests from Google
I want to deprecate (turn off/not send HTTP responses) for some old HTML &
I have to set up push cloud notification server. I decided to use: http://pypi.python.org/pypi/pyapns/
I am trying to write a simple http post which will send a json
I want to send a simple string from Python 3 to a PHP site

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.