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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:20:23+00:00 2026-05-23T01:20:23+00:00

I’m reading Pro Android 2 which contains an excellent Service example as follows: import

  • 0

I’m reading “Pro Android 2” which contains an excellent Service example as follows:

    import android.app.Service;
    import android.content.Intent;
    import android.os.IBinder;
    import android.util.Log;

    public class TestService1 extends Service {
        private static final String TAG = "TestService1";

        @Override
        public void onCreate() {
            Log.d(TAG, "onCreate");
            super.onCreate();
        }

        @Override
        public IBinder onBind(Intent intent) {
            Log.d(TAG, "onBind");
            return null;
        }
     }

I also added the service definition entry as a child of:

    <application> in my AndroidManifest.xml as follows:

    <service android:name="TestService1"></service>

The book then says:”The next obvious question is how to do you call the service?”

And that’s precisely what I want to know!!! I’ve scoured the book and I don’t see how to start up the service. The book actually seems to indicate that the service is called on start up. Maybe I’ve just misunderstood this part.

This is just experimental and I just want to see the service run and see the Log messages in logcat. The book says:”The system calls onCreate() when the service is first created, but before calling onStart(). This process, which resembles the process for creating an activity, provides a way for the service to perform one-time initialization at startup.”

Well ok, but I’m not sure what to do to start the service except perhaps in my primary activity’s onCreate() do something like:

    Intent TestService1 = new Intent(this,com.mydomain.myproject.TestService1.class);
    startActivity(TestService1);

But when I do this I get THE error: “The application … has stopped unexpectedly.”

I think this problem has a simple solution, but I’m just too simple to see it:)

  • 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-23T01:20:24+00:00Added an answer on May 23, 2026 at 1:20 am

    You’re very close. A service is not an activity, so you can’t use startActivity to start it. Instead, use the similarly named startService method.

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

Sidebar

Related Questions

No related questions found

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.