break;
}
- if(pref.getBoolean("taskbar_active", false) && !isServiceRunning())
+ if(pref.getBoolean("taskbar_active", false) && !U.isServiceRunning(this, NotificationService.class))
editor.putBoolean("taskbar_active", false);
// Ensure that components that should be enabled are enabled properly
stopService(new Intent(this, NotificationService.class));
}
- private boolean isServiceRunning() {
- ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
- for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
- if(NotificationService.class.getName().equals(service.service.getClassName()))
- return true;
- }
-
- return false;
- }
-
@TargetApi(Build.VERSION_CODES.M)
private boolean canDrawOverlays() {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(this);
stopTaskbarService(true);
startTaskbarService(true);
- } else if(isServiceRunning()) {
+ } else if(U.isServiceRunning(this, StartMenuService.class)) {
stopTaskbarService(false);
startTaskbarService(false);
}
}
-
- private boolean isServiceRunning() {
- ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
- if(StartMenuService.class.getName().equals(service.service.getClassName()))
- return true;
- }
-
- return false;
- }
}
break;
case Intent.ACTION_ASSIST:
- if(getIntent().hasExtra(Intent.EXTRA_ASSIST_INPUT_HINT_KEYBOARD) && isServiceRunning()) {
+ if(getIntent().hasExtra(Intent.EXTRA_ASSIST_INPUT_HINT_KEYBOARD) && U.isServiceRunning(this, StartMenuService.class)) {
LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_START_MENU"));
} else {
Intent intent = new Intent("com.google.android.googlequicksearchbox.TEXT_ASSIST");
finish();
}
-
- private boolean isServiceRunning() {
- ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
- for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
- if(StartMenuService.class.getName().equals(service.service.getClassName()))
- return true;
- }
-
- return false;
- }
}
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
-import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
stopTaskbarService(true);
startTaskbarService(true);
- } else if(isServiceRunning()) {
+ } else if(U.isServiceRunning(getActivity(), StartMenuService.class)) {
stopTaskbarService(false);
startTaskbarService(false);
}
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M || Settings.canDrawOverlays(getActivity());
}
- private boolean isServiceRunning() {
- ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
- for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
- if(StartMenuService.class.getName().equals(service.service.getClassName()))
- return true;
- }
-
- return false;
- }
-
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 123 && resultCode == Activity.RESULT_OK) {
package com.farmerbb.taskbar.receiver;
-import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
context.startService(new Intent(context, NotificationService.class));
} else {
- editor.putBoolean("taskbar_active", isServiceRunning(context));
+ editor.putBoolean("taskbar_active", U.isServiceRunning(context, NotificationService.class));
editor.apply();
}
}
-
- private boolean isServiceRunning(Context context) {
- ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
- if(NotificationService.class.getName().equals(service.service.getClassName()))
- return true;
- }
-
- return false;
- }
}
package com.farmerbb.taskbar.util;
import android.annotation.TargetApi;
+import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.AlertDialog;
+import android.app.Service;
import android.app.admin.DevicePolicyManager;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
|| Settings.Global.getInt(context.getContentResolver(), "enable_freeform_support", -1) == 1
|| Settings.Global.getInt(context.getContentResolver(), "force_resizable_activities", -1) == 1);
}
+
+ public static boolean isServiceRunning(Context context, Class<? extends Service> cls) {
+ ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
+ if(cls.getName().equals(service.service.getClassName()))
+ return true;
+ }
+
+ return false;
+ }
}