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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:54:59+00:00 2026-06-12T22:54:59+00:00

Hi there im using http://code.google.com/p/aacdecoder-android/ heres my main activity full code: http://pastebin.com/FmaVgfNP but now

  • 0

Hi there im using http://code.google.com/p/aacdecoder-android/ heres my main activity full code: http://pastebin.com/FmaVgfNP but now i want to put that app in the background so when people press back button the app stays streaming audio i tried using this: basically the app have two activities one listview then when i click in one item it autoplays the stream for that station but when i press back button my streams stops, i tried to create a service like this:

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


    @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");

        //player = MediaPlayer.create(this, R.raw.braincandy);
        //player.setLooping(false); // Set looping
    }

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

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

i tried this code to configure service in my activity:

startService(new Intent(this, MyService.class));

in my main activity when aacplayer starts

then when stops i put this:

stopService(new Intent(this, MyService.class));

i tried to put in MyService.class oncreate the function multiPlayer.playAsync( getUrl()); so the audio stream keeps streaming when people press back button.

but im getting this error:

10-16 02:02:07.760: E/AndroidRuntime(25638): java.lang.RuntimeException: Unable to start service com.spoledge.aacplayer.MyService@41b40ca0 with Intent { cmp=com.spoledge.aacplayer/.MyService }: java.lang.NullPointerException

i dont know if im doing right with the logic im not very clear about when my player streams the audio i can register that action as a service so it keeps in background.

thanks very much.

  • 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-12T22:55:00+00:00Added an answer on June 12, 2026 at 10:55 pm

    Ive done this before using a bound service. Bound is better as it allows you to easily implement pause/stop/play, etc. If your activity is killed by the system while in the background, it can re-bind to the service when the user brings it back up, which re-enabled control of playback.

    I’m not sure if it is bad practice to post links to my own blog but the full source code is here at http://www.speakingcode.com/2012/02/22/creating-a-streaming-audio-app-for-android-with-android-media-mediaplayer-android-media-audiomanager-and-android-app-service/

    If linking is not preferred I’ll duplicate the solution here, but it is lengthy 🙂 good luck and happy coding!

    If you want to use a started service like yuo are doing, and forfeit the benefits of a bound service, then you need to move your MediaPlayer object entirely into the service and out of the activity. you can instantiate the MediaPlayer in your onCreate() but it will be better to start it (call playAsync()) in the onStartCommand() method.

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

Sidebar

Related Questions

I am using http://code.google.com/p/feedparser/ to write a simple news integrator. But I want pure
so I'm using fancybox, as well as Google's minify http://code.google.com/p/minify/ but then after minifying
I am using the control library from http://code.google.com/p/gong-wpf-dragdrop/successfully for my listbox dragging operation.But there
I'm using this: http://code.google.com/p/svg-edit/ I put a hard coded code inside the svgcanvas div
in Redis ( http://code.google.com/p/redis ) there are scores associated to elements, in order to
When using this jquery plugin: http://code.google.com/p/jqueryrotate/wiki/Documentation and I rotate an image 90 degrees either
I was just trying to convert a PPT using the following URL http://code.google.com/p/qifei/wiki/PDFConverter python
I am using bitlyj snapshot jar to shorten URLs from the following link. http://code.google.com/p/bitlyj/downloads/list
I'm using the wonderfully lightweight jQuery minitabs plugin from: http://code.google.com/p/minitabs/ which is a lovely
I have a form which is built dynamically using this jQuery plugin http://code.google.com/p/jquery-dynamic-form/ When

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.