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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:15:08+00:00 2026-06-04T15:15:08+00:00

I have a server running on an android device as a Service . I

  • 0

I have a server running on an android device as a Service. I want the user to enter the clients number and then the service starts. Is there a better way to take care of this instead of passing data from an activity to a Service?

Furthermore, when i use the above approach it seems that the client hangs and forces the application to destroy. Here is the code:

String a = clients.getText().toString();
Bundle bundle = new Bundle();
bundle.putCharSequence("NumberOfClients", a);           
Intent intent = new Intent(Manage.this, Server.class);
intent.putExtras(bundle);
Log.d("hi", a);
startService(intent);

And here is the Server:

@Override
public void onCreate() 
{                         
    Thread server = new Thread(new ServerThread());
    server.start();                 
}

public int onStartCommand(Intent intent, int flags, int startId) {
     super.onStartCommand(intent, flags, startId);       
     Bundle bundle = new Bundle();
     bundle = intent.getExtras();
     numberofclients = (String) bundle.getCharSequence("NumberOfClients");
     int a = Integer.parseInt(numberofclients);     

     return a;
    }

When I hit the button to connect to the server the client hangs. Why is this happening?

  • 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-04T15:15:10+00:00Added an answer on June 4, 2026 at 3:15 pm

    onStartCommand is supposed to return a predefined value on how to treat the service.
    It looks like you’d want a START_NOT_STICKY
    So in your return statement in onStartCommand, that’s what you’d be returning. i.e.

    return START_NOT_STICKY;
    

    If you want to save your integer a for use somewhere else in the service, create a global variable and set it equal to a.

    Refer to Android Docs on Service
    http://developer.android.com/reference/android/app/Service.html#START_CONTINUATION_MASK

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

Sidebar

Related Questions

I have a socket server running on an android device. Then from a client
So I have a django server running on my local machine that I want
I have to implement a client-server architecture where there are many android client located
Have a server-socket running in an android application, which I debug using the emulator.
The server will be running php and the device could be iphone or android
I have a server running a 3gb JVM with a 750 meg permgen space.
I have a server running on the Amazon cloud running ColdFusion 9.0.1. on Windows
Strange issue. I have SQL Server running on an EC2 box that I can
I have development server setup running Adobe Coldfusion8 (.war install) on top of Caucho
I have a bluetooth server running on my Ubuntu desktop written using PyBlueZ. That

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.