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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:30:44+00:00 2026-06-07T02:30:44+00:00

Probably an easy question for you guys, but its my first attempt at creating

  • 0

Probably an easy question for you guys, but its my first attempt at creating a service that should run in the background when my app closes. My problem is: The service doesnt start when I click on my “start service” button. I don’t see any of the toast, and nothing in the logcat (no errors either). Thanks in advance!

Service class

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

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onCreate() {
    Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onCreate");

}

@Override
public void onDestroy() {
    Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onDestroy");

}

@Override
public void onStart(Intent intent, int startid) {
    Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
    Log.d(TAG, "onStart");

}
}

My main activity

public void startServiceClick(View v){

    Log.d("foo", "onClick: starting srvice");
    startService(new Intent(this, MyService.class));
}

public void stopServiceClick(View v){

    Log.d("foo", "onClick: stopping srvice");
    stopService(new Intent(this, MyService.class));
}

Manifest xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.johanberntsson.main"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="15" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>

<application
    android:icon="@drawable/maps1"
    android:label="@string/app_name" >
    <uses-library android:name="com.google.android.maps" />
    <activity
        android:name=".LongitudeActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".DebugActivity" />
    <activity android:name=".GoogleMapsActivity" />

    <service android:enabled="true" android:name=".MyService" />

</application>

</manifest>
  • 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-07T02:30:46+00:00Added an answer on June 7, 2026 at 2:30 am
    this is suggestion as all else looking fine 
    

    should call super in each function like super.onCreate();

    as may be possible service is already started and try to stop and start again and check it toast appears ….

    try

    <service android:enabled="true" android:name="se.johanberntsson.servies.MyService" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really easy question, but I can't find anything that works.
probably an easy question, but I am confused: When I run the following script
I know this is probably an easy question for most of you guys. But
This is probably an easy question, but I'd like to iterate through the tags
Ok, I think this is probably an easy question but for the life of
The question is probably extremely easy to resolve, but I need to resolve it
Here is probably an easy question.. but I am really struggling so help is
Probably far too easy question, but how do I match a file extension such
This is probably a very easy question to answer, but for the life of
I am new to Rails so this is probably an easy question but can't

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.