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.