Skip to content

Commit

Permalink
Update MusicControlNotification.java
Browse files Browse the repository at this point in the history
  • Loading branch information
hiennguyen92 authored Jun 30, 2020
1 parent ddc5bec commit c28a931
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,23 @@ public void forceForeground() {
@Override
public void onCreate() {
super.onCreate();
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
startForeground(NOTIFICATION_ID, notification);
try {
if (MusicControlModule.INSTANCE.notification == null) {
MusicControlModule.INSTANCE.init();
}
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
startForeground(NOTIFICATION_ID, notification);
}catch (Exception ex){
ex.printStackTrace();
}
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (MusicControlModule.INSTANCE.notification == null) {
MusicControlModule.INSTANCE.init();
}
notification = MusicControlModule.INSTANCE.notification.prepareNotification(MusicControlModule.INSTANCE.nb, false);
startForeground(NOTIFICATION_ID, notification);
}
Expand Down

1 comment on commit c28a931

@rborn
Copy link

@rborn rborn commented on c28a931 Aug 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hiennguyen92 , I tested this code and it seems to work great, do you mind if I make a PR to the main repo so everyone can benefit from it?

tanguyantoine#266 (comment)

I have my fork where I applied your patch, synced with master and added another small fix. Or maybe you could also do it, but if you don't have the time I can help 😻

Thank you!

Please sign in to comment.