List of usage examples for android.content Context ACTIVITY_SERVICE
String ACTIVITY_SERVICE
To view the source code for android.content Context ACTIVITY_SERVICE.
Click Source Link
From source file:com.air.mobilebrowser.BrowserActivity.java
@Override public void onPause() { ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List<RunningTaskInfo> tasks = am.getRunningTasks(1); ComponentName topActivity = tasks.get(0).topActivity; String packageName = topActivity.getPackageName(); if (!packageName.equals(super.getPackageName()) && !packageName.equals("android")) { mBeenBackgrounded = true;// w ww . j a v a 2s . c o m executeAIRMobileFunction(JSNTVCmds.NTV_ENTER_BACKGROUND, null); } mWebView.onPause(); super.onPause(); }
From source file:com.gm.goldencity.util.Utils.java
/** * Checking a service is running or not/*from www .j av a2s.c o m*/ * * @param context Application context * @param myService Set your service class * @return */ public static boolean isServiceRunning(Context context, Class<?> myService) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (myService.getName().equals(service.service.getClassName())) { return true; } } return false; }
From source file:com.taobao.weex.utils.WXUtils.java
public static long getAvailMemory(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); am.getMemoryInfo(mi);/* w w w .j a va 2 s . c om*/ //mi.availMem; ?? //return Formatter.formatFileSize(context, mi.availMem);// ?? WXLogUtils.w("app AvailMemory ---->>>" + mi.availMem / (1024 * 1024)); return mi.availMem / (1024 * 1024); }
From source file:org.godotengine.godot.Godot.java
public int getGLESVersionCode() { ActivityManager am = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE); ConfigurationInfo deviceInfo = am.getDeviceConfigurationInfo(); return deviceInfo.reqGlEsVersion; }
From source file:com.ruesga.rview.misc.BitmapUtils.java
public static int calculateMaxAvailableSize(Context context) { if (AndroidHelper.isJellyBeanOrGreater()) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); return (int) ((mi.totalMem / 1073741824) * 1024); }//from w ww .j ava2s . co m // The minimum for all android devices return 1024; }
From source file:com.packetsender.android.MainActivity.java
public RunningServiceInfo getServiceIntent() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.packetsender.android.PacketListenerService".equals(service.service.getClassName())) { return service; }/* ww w. j a va 2 s .co m*/ } return null; }
From source file:fr.s13d.photobackup.preferences.PBPreferenceFragment.java
private boolean isPhotoBackupServiceRunning() { final Activity activity = getActivity(); if (activity != null) { final ActivityManager manager = (ActivityManager) getActivity() .getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { boolean sameClass = PBService.class.getName().equals(service.service.getClassName()); boolean samePackage = BuildConfig.APPLICATION_ID.equals(service.service.getPackageName()); if (sameClass && samePackage) { Log.i(LOG_TAG, "Service is running"); return true; }//from w w w .java2 s.co m } } Log.i(LOG_TAG, "Service or activity is NOT running"); return false; }
From source file:com.nxp.ltsm.ltsmclient.tools.Utils.java
static String getForeGroundL(Context context) { final int PROCESS_STATE_TOP = 2; RunningAppProcessInfo currentInfo = null; Field field = null;/*from w ww .ja v a2 s .c om*/ try { field = RunningAppProcessInfo.class.getDeclaredField("processState"); } catch (Exception e) { e.printStackTrace(); } ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> appList = am.getRunningAppProcesses(); for (RunningAppProcessInfo app : appList) { if (app.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND && app.importanceReasonCode == 0) { Integer state = null; try { state = field.getInt(app); } catch (Exception e) { e.printStackTrace(); } if (state != null && state == PROCESS_STATE_TOP) { currentInfo = app; break; } } } return currentInfo.processName; }
From source file:com.prey.PreyPhone.java
private long getMemoryRamSize() { ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(mInfo); return (mInfo.threshold >> 20); }
From source file:me.piebridge.prevent.framework.SystemReceiver.java
private Map<String, Set<Long>> getRunningAppProcesses(Context context) { Map<String, Set<Long>> running = new HashMap<String, Set<Long>>(); Set<String> services = getRunningServices(context); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> processes = activityManager.getRunningAppProcesses(); if (processes == null) { PreventLog.w("cannot get running processes"); return running; }// w w w. j av a 2 s . c o m for (ActivityManager.RunningAppProcessInfo process : processes) { for (String pkg : process.pkgList) { Set<Long> importance = running.get(pkg); if (importance == null) { importance = new LinkedHashSet<Long>(); running.put(pkg, importance); } if (process.importance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE) { importance.add((long) process.importance); } else if (services.contains(pkg)) { importance.add((long) process.importance); } else { importance.add((long) -process.importance); } } } return running; }