SHARE
TWEET

Untitled

a guest Jun 20th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void servicioOnline(){
  2.  
  3.  
  4.     final ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  5.  
  6.     final List<ActivityManager.RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE);
  7.     for (int i = 0; i < services.size(); i++) {
  8.         String packageClassName = services.get(i).service.getClassName();
  9.         if (packageClassName.equals("nombre_paquete_de_la_otra_apk")) {
  10.  
  11.             System.out.println("Service Nr. " + i + " :" + services.get(i).service);
  12.             System.out.println("Service Nr. " + i + " package name : " + services.get(i).service.getPackageName());
  13.             System.out.println("Service Nr. " + i + " class name : " + packageClassName);
  14.  
  15.             //return true;
  16.         }else{
  17.             System.out.println("hay problemas...");
  18.         }
  19.  
  20.     }
  21.     //return false;
  22. }
  23.      
  24. public static boolean verAppEjecutada(final Context context, final String packageName) {
  25.         final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  26.         final List<ActivityManager.RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
  27.         if (procInfos != null)
  28.         {
  29.             for (final ActivityManager.RunningAppProcessInfo processInfo : procInfos) {
  30.                 if (processInfo.processName.equals(packageName)) {
  31.                     return true;
  32.                 }
  33.             }
  34.         }
  35.         return false;
  36.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top