From 1d171d82f1f465587f09414a95e60ec3ecc27b36 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Thu, 19 Mar 2015 11:55:29 +0100 Subject: [PATCH] fix #2437: clear uploading posts state if the PostUploadService is not running during PostList creation --- .../org/wordpress/android/util/ServiceUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 WordPressUtils/src/main/java/org/wordpress/android/util/ServiceUtils.java diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/ServiceUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/ServiceUtils.java new file mode 100644 index 000000000000..6bcfde06b892 --- /dev/null +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/ServiceUtils.java @@ -0,0 +1,16 @@ +package org.wordpress.android.util; + +import android.app.ActivityManager; +import android.content.Context; + +public class ServiceUtils { + public static boolean isServiceRunning(Context context, Class serviceClass) { + ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); + for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { + if (serviceClass.getName().equals(service.service.getClassName())) { + return true; + } + } + return false; + } +}