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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:20:30+00:00 2026-05-29T23:20:30+00:00

I’m about to start making an app that’s supposed to act as a tcp

  • 0

I’m about to start making an app that’s supposed to act as a tcp chat client and I’ve been reading and reading and I’ve come to the conclusion that it would be best (if not required?) to put my socket and reader in asynctask.

Thing is I’m not sure on where to begin, as I’m new to android this is a massive undertaking for me at least but the basics as far as I’ve understood it.

  1. Instantiate the views in the mainclass and create a method for sending text from a EditText to the async class.

  2. Create the async class, with the socket and the connection, place the reader here and the writer, the writer will be a method to take in a string parameter which is sent through the socket.

  3. Somehow make my reader constantly listen to the server socket and update my textview with strings that are sent out.

Is this a good basic “plan” to start programming for or is it flawed somehow or me missing something? One question that I got before even starting is the async task, do I make it ? As far as I’m aware I don’t need to return anything and I won’t be needing any progress updating? My address for the client will be hardcoded so I’m guessing that’s the only thing I would want to pass a parameter to the async class?

Sorry if its basic but I’m just starting and would like to not start off wrong.

  • 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-05-29T23:20:32+00:00Added an answer on May 29, 2026 at 11:20 pm

    You only want to use an AsyncTask for small (relatively) and direct actions, such as downloading specific items (eg. Images or mp3’s). It sounds like what you want is, instead, a Service. The service will run in the background of your application and you can handle your network actions through the service.

    For other helpful documentation and help on seeing if the Service is right for you, look here.

    Edit:

    For more information of creating a Service in its own Thread, refer to this.

    Edit 2:

    Try to think of is as the anti-Activity. It does everything that an activity should not have to do, primarily, processing. Any hardcore processing should be done in a threaded service for many reasons, primarily for multi-tasking and taking processing off the main UI thread. To demostrate this, think of Pandora. Pandora creates a service (in its own thread) that connects to its site and streams music. The service has a life cycle that will allow it to live while the activities are killed. This allows the music to stream will the user does other tasks. But when the user wants to look at what is playing, she will only have to click into the app. From there the activity will check the service, see that it has some data, and base its content off of the data in the service.

    I hope this helps. I really can’t think of a better why to put it….

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

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.