Set Aac+player app as service in background
<p>Hi there im using <a href="http://code.google.com/p/aacdecoder-android/" rel="nofollow">http://code.google.com/p/aacdecoder-android/</a> heres my main activity full code: <a href="http://pastebin.com/FmaVgfNP" rel="nofollow">http://pastebin.com/FmaVgfNP</a> 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:</p>

<pre><code>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();
    }
}
</code></pre>

<p>i tried this code to configure service in my activity:</p>

<pre><code>startService(new Intent(this, MyService.class));
</code></pre>

<p>in my main activity when aacplayer starts</p>

<p>then when stops i put this:</p>

<pre><code>stopService(new Intent(this, MyService.class));
</code></pre>

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

<p>but im getting this error:</p>

<pre><code>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
</code></pre>

<p>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. </p>

<p>thanks very much.</p>
