Skip to content
Snippets Groups Projects
Commit 227ef2e8 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Oreo: Add isForeground() utility method

parent 475145c1
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
package org.videolan.vlc.util;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
......@@ -149,6 +150,7 @@ public class Util {
for (T newItem : items) {
for (T oldItem : dataset) {
if (newItem.equals(oldItem)) {
//noinspection UnusedAssignment
oldItem = newItem;
continue outer;
}
......@@ -166,4 +168,17 @@ public class Util {
contentBuilder.append(album);
return contentBuilder.toString();
}
/**
* Starts a service in Foreground in Android 8+
* To be removed with AppCompat 26+
* @param ctx the context
* @param intent service intent to start
*/
public static void startService(Context ctx, Intent intent) {
if (VLCApplication.isForeground())
ctx.startService(intent);
else
ctx.startForegroundService(intent);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment