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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:03:13+00:00 2026-06-09T07:03:13+00:00

I m trying to run an android source code in eclipse. The targetSdkVerison for

  • 0

I m trying to run an android source code in eclipse. The targetSdkVerison for this app is 5 . I m totally new to android and have installed the latest api’s ( Android 4.1) . In some part of the code I m getting errors such as

    public void hideNotification(Service context)
    {
        context.setForeground(false);// error: The method setForeground(boolean) is undefined for the type Service
        getNotificationManager(context).cancel(NOTIF_PLAYING);
    }



    public void showNotification(Service context, long songId)
    {
        context.startForeground(NOTIF_PLAYING, newNotification(context, songId));//error :Call requires API level 5 (current min is 3): android.app.Service#startForeground
    }

I guess these are because incompatibility between different versions of sdk . How can I resolve the same ?

  • 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-09T07:03:16+00:00Added an answer on June 9, 2026 at 7:03 am

    Firstly, setForeground(...) has been deprecated, and is no longer usable. See this blog for more details.

    You are getting this error because your minimum SDK level, defined in the manifest, is 3. startForeground(...) requires API 5+.

    Now, in order to solve this, you cannot support anything below API 5; according to Dashboards, 99.3% of users have migrated to APIs 5+. To do this, set your minSdkVersion to 5, and remove your call to setForeground(...). (This will solve both error messages.)

    Note: setForeground(...) has since been removed from the SDK, and should no longer be used, ever, at all.

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

Sidebar

Related Questions

I have this problem when trying to run hello world program using android SDK.
I'm trying to compile and run the task-android-sample code from Google's API website. I
I'm trying to get the android source code. When I run: $ repo init
I'm trying to run an android app from eclipse on my device (moto droid2).
I can run this code in Android app (using PhoneGap adn jQuery Mobile) but
I m trying to run the code given here - http://code.google.com/p/android-honeycomb-fragment-tutorial/source/browse/#svn%2Ftrunk%253Fstate%253Dclosed on a 7
I'm trying to run a mp3 file using android media player. I'm using this
I'm trying to be able to run my mobile app on my android phone,
I am new to android development . I'm trying to download and run the
I am trying to debug the android source using Eclipse by following the instructions

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.