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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:03:03+00:00 2026-06-17T10:03:03+00:00

I was wondering if someone could help me with debugging. I am currently using

  • 0

I was wondering if someone could help me with debugging. I am currently using the code in:

Sending Email in Android using JavaMail API without using the default/built-in app

and have used all of the code as directed. After inputting my email fields, I was unable to get email to be sent. I noticed a piece of code in GMailSender.java, where it seemed that there was a missing piece of code.

}catch(Exception e){

}

Knowing that I had debugged every other part of the code, I added a Log.e, as so.

}catch(Exception e){
    Log.e("GmailDebug", e.getMessage(), e); 
}

As a result, I noticed that I got the following logs.

01-16 22:22:38.933: E/GmailDebug(4487): null
01-16 22:22:38.933: E/GmailDebug(4487): android.os.NetworkOnMainThreadException

After commenting out the lines beforehand and systematically uncommenting them, I finally was able to determine that I didn’t get any logs until I uncommented the line

Transport.send(message);

Can someone help me out, and tell me how I can prevent these errors? 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-17T10:03:04+00:00Added an answer on June 17, 2026 at 10:03 am

    This happens because you are doing a network operation on the main thread, and this is not allowed on Android 3.0 and above. Even though it is in a service, services are run on the UI thread unless you specifically launch them in another thread or create a thread inside it.

    You can fix this by running the task in a background thread off the main UI thread, by using a Thread or an AsyncTask.

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

Sidebar

Related Questions

Im wondering if someone could help me out. Currently to view a users profile
I was wondering if someone could help me. I have started using version control
I was wondering if someone could help me with the performance of this code
I was wondering if someone could help me debug the following OCaml code that
I was wondering if someone could help me out. I am using cakePHP 1.3
I was wondering if someone could help me understand what this code is doing.
I am wondering if someone could help me with some probably rather simple code,
I was wondering if someone could help me using the JQuery validation plugin. I
I was wondering if someone could help me. Im trying to integrate some code
I was wondering if someone could help with with some jquery code for doing

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.