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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:41:59+00:00 2026-06-18T05:41:59+00:00

I have an android app with multiple activities. One needed class contains a socket

  • 0

I have an android app with multiple activities. One needed class contains a socket connection server.

I am deciding to make this server class either as a nested sub class in the main activity or extend Service to run in the background as a service class.

Some people have commented that the service can really burn down the users battery and I have found that it is hard to kill a service class. I sometimes use a notification in the top menu so a user can stop the service and the app with a button click. but when the user does this it gives an error message that looks like the app crashed and that does not look kosher.

by putting the socket server class in a blank activity that contains no xml layout file it will probably bring up a blank page that will lose focus from the main activity, and that will not look good, unless there is some way to get around this problem.

one alternative idea is to put the socket server inside of a utility class that does not extend any other class and use a nested broadcast receiver or intents to send messages back to the main activity.

another alternative idea is the put the socket server inside of a class that extends application.

what is the correct way to implement this socket server class?

  • 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-18T05:42:00+00:00Added an answer on June 18, 2026 at 5:42 am

    we have a (bluetooth) server socket that runs in a thread in a dedicated service with no issues reported by users.

    Some people have commented that the service can really burn down the users battery

    In my opinion you should “Suck it and see” ie unless you try it and test it you’ll never know. Yes, there are alternatives and yes it will take more than zero additional battery, but test it and take measurements.

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

Sidebar

Related Questions

I have Android client app that communicates with server using Socket . On my
I'm starting an Android app which will have multiple Activities. It will be using
I have an a Java Android app that calls different activities. I thought this
In my Android app I have multiple activities using different array resources and I
I have an Android app that has an Application class and I have another
Here's the problem. In my app, I have 5 tabs which contains activities. In
I'm writing an app and I want one of my activities to have a
Is this possible in an Android app? I want to make it so that
I have an android app that has mutliple activities The first main activity starts
To begin with, this is the first Android app I'm writing, and 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.