Fix widget PendingIntents on Oreo+
Thanks to KBerstene https://github.com/daneren2005/Subsonic/pull/957
This commit is contained in:
parent
b943580fa8
commit
e12fbf68ad
|
@ -34,6 +34,7 @@ import android.graphics.PorterDuff.Mode;
|
|||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
@ -286,19 +287,28 @@ public class AudinautWidgetProvider extends AppWidgetProvider {
|
|||
intent = new Intent("Audinaut.PLAY_PAUSE");
|
||||
intent.setComponent(new ComponentName(context, DownloadService.class));
|
||||
intent.setAction(DownloadService.CMD_TOGGLEPAUSE);
|
||||
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
|
||||
if (Build.VERSION.SDK_INT >= 26)
|
||||
pendingIntent = PendingIntent.getForegroundService(context, 0, intent, 0);
|
||||
else
|
||||
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
|
||||
views.setOnClickPendingIntent(R.id.control_play, pendingIntent);
|
||||
|
||||
intent = new Intent("Audinaut.NEXT"); // Use a unique action name to ensure a different PendingIntent to be created.
|
||||
intent.setComponent(new ComponentName(context, DownloadService.class));
|
||||
intent.setAction(DownloadService.CMD_NEXT);
|
||||
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
|
||||
if (Build.VERSION.SDK_INT >= 26)
|
||||
pendingIntent = PendingIntent.getForegroundService(context, 0, intent, 0);
|
||||
else
|
||||
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
|
||||
views.setOnClickPendingIntent(R.id.control_next, pendingIntent);
|
||||
|
||||
intent = new Intent("Audinaut.PREVIOUS"); // Use a unique action name to ensure a different PendingIntent to be created.
|
||||
intent.setComponent(new ComponentName(context, DownloadService.class));
|
||||
intent.setAction(DownloadService.CMD_PREVIOUS);
|
||||
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
|
||||
if (Build.VERSION.SDK_INT >= 26)
|
||||
pendingIntent = PendingIntent.getForegroundService(context, 0, intent, 0);
|
||||
else
|
||||
pendingIntent = PendingIntent.getService(context, 0, intent, 0);
|
||||
views.setOnClickPendingIntent(R.id.control_previous, pendingIntent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue