Commit 7e88b95d authored by Ludovic Fauvet's avatar Ludovic Fauvet
Browse files

AudioService: use the new notification api thru the compat library

In addition to improving the look and feel on Android 4.1, it also kills
some deprecation warnings.
parent 67847a16
......@@ -60,6 +60,7 @@ import android.os.Message;
import android.os.RemoteException;
import android.os.SystemClock;
import android.provider.MediaStore;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.KeyEvent;
......@@ -85,7 +86,6 @@ public class AudioService extends Service {
private Media mCurrentMedia;
private HashMap<IAudioServiceCallback, Integer> mCallback;
private EventManager mEventManager;
private Notification mNotification;
private boolean mShuffling = false;
private RepeatType mRepeating = RepeatType.None;
private boolean mDetectHeadset = true;
......@@ -456,23 +456,26 @@ public class AudioService extends Service {
private void showNotification() {
// add notification to status bar
if (mNotification == null) {
mNotification = new Notification(R.drawable.icon, null,
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
Intent notificationIntent = new Intent(this, AudioPlayerActivity.class);
notificationIntent.putExtra(START_FROM_NOTIFICATION, true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
mNotification.setLatestEventInfo(this, mCurrentMedia.getTitle(),
mCurrentMedia.getArtist() + " - " + mCurrentMedia.getAlbum(), pendingIntent);
startForeground(3, mNotification);
private void hideNotification() {
mNotification = null;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment