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

  • Home
  • SEARCH
  • 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 8729745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:53:14+00:00 2026-06-13T08:53:14+00:00

I am trying to learn about the Service class in Android. I have created

  • 0

I am trying to learn about the Service class in Android.

I have created a very simple activity:

public class ServiceLauncher extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_service_launcher);
    Intent intent = new Intent(this, NavOverrideService.class);
    startService(intent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_service_launcher, menu);
    return true;
}

}

this activity is supposed to call the following service, but it appears that it is not as none of my logs or toast messages are showing:

   public class NavOverrideService extends Service{

    /* (non-Javadoc)
     * @see android.app.Service#onBind(android.content.Intent)
     */

    @Override
    public void onCreate() {
      // Start up the thread running the service.  Note that we create a
      // separate thread because the service normally runs in the process's
      // main thread, which we don't want to block.  We also make it
      // background priority so CPU-intensive work will not disrupt our UI.
        Log.v("Nav Service: ","Created");
        View disableStatusBar = new TableLayout(getApplicationContext());
        //mView = new HUDView(getApplicationContext());


         WindowManager.LayoutParams handleParams = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.FILL_PARENT,
                50,
                 // This allows the view to be displayed over the status bar
               // WindowManager.LayoutParams.TYPE_SYSTEM_ALERT |  
                WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                 // this is to keep button presses going to the background window
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
                 // this is to enable the notification to recieve touch events
                WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
                 // Draws over status bar
                WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                 PixelFormat.TRANSPARENT);

         handleParams.gravity = Gravity.TOP;
         handleParams.y = 750;

         //disableStatusBar.setBackgroundColor(Color.GREEN);
         disableStatusBar.setBackgroundResource(R.drawable.fake_nav);


         WindowManager winMgr = (WindowManager)getSystemService(WINDOW_SERVICE); 


         winMgr.addView(disableStatusBar, handleParams);


    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();

        Log.v("Nav Service: ","started");

        // If we get killed, after returning from here, restart
        return START_REDELIVER_INTENT;
    }

    @Override
    public IBinder onBind(Intent intent) {
        // We don't provide binding, so return null
        return null;
    }

    @Override
    public void onDestroy() {
      Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show(); 
    }
}

what am i doing wrong?

oh and my manifest :

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <service android:name="com.eliddell.services_test.NavOverrideService" />
    <activity
        android:name="com.eliddell.services_test.ServiceLauncher"
        android:label="@string/title_activity_service_launcher" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
  • 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-13T08:53:15+00:00Added an answer on June 13, 2026 at 8:53 am

    I have create a new project.
    It is works for me:

    public class MainActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            startService(new Intent(this, ServiceTest.class));
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
    }
    
    
    public class ServiceTest extends Service {
    
        @Override
        public void onCreate() {
            Log.v(null, "SERVICE TEST onCreate");
            super.onCreate();
        }
    
        @Override
        public void onStart(Intent intent, int startId) {
            Log.v(null, "SERVICE TEST onStart");
            super.onStart(intent, startId);
        }
    
    
        @Override
        public IBinder onBind(Intent intent) {
            return null;
        }
    
    }
    
    
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.servicetest"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".MainActivity"
                android:label="@string/title_activity_main" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <service android:name="ServiceTest"></service>
        </application>
    
    </manifest>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to learn about php's arrays today. I have a set of arrays like
i'm trying to learn about user controls. I created a user control that has
I have been trying to learn about classes in PHP and part of my
I am trying to learn about Google maps API. I have a project that
I have trying to learn about resources. In VS when I create the project:
I am somewhat new to jQuery but have been having fun trying learn about
I am trying to make a simple form activity in order to learn how
I'm trying to learn about Expression trees, and I've created a method that takes
I'm trying learn more about RavenDB and at the moment to focus on how
I am trying to learn about the ScriptProperties object in GAS. I tried setting

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.