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:cn.videochat.VideoChat.java
public static boolean IsSupportOpenGLES2(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo(); return configurationInfo.reqGlEsVersion >= 0x20000; }
From source file:org.androidpn.client.NotificationReceiver.java
/** * ????//from ww w . j a v a 2s . c o m * * @param context * @param serviceName * ??+???net.loonggg.testbackstage.TestService * @return true?false?? */ public boolean isServiceWork(Context context, String serviceName) { boolean isWork = false; ActivityManager myAM = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> myList = myAM.getRunningServices(40); if (myList.size() <= 0) { return false; } for (int i = 0; i < myList.size(); i++) { String mName = myList.get(i).service.getClassName().toString(); if (mName.equals(serviceName)) { isWork = true; break; } } return isWork; }
From source file:net.mceoin.cominghome.MainActivity.java
/** * Call using isMyServiceRunning(MyService.class) * http://stackoverflow.com/questions/600207/how-to-check-if-a-service-is-running-in-android *///ww w.j av a2s .c om public static boolean isMyServiceRunning(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; }
From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java
private static void appendDeviceInfo(final Appendable report, final Context context) throws IOException { final Resources res = context.getResources(); final android.content.res.Configuration config = res.getConfiguration(); final ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context .getSystemService(Context.DEVICE_POLICY_SERVICE); report.append("Device Model: " + Build.MODEL + "\n"); report.append("Android Version: " + Build.VERSION.RELEASE + "\n"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n"); report.append("ABIs: ") .append(Joiner.on(", ").skipNulls() .join(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? supportedAbisLollipop() : supportedAbisKitKat())) .append("\n"); report.append("Board: " + Build.BOARD + "\n"); report.append("Brand: " + Build.BRAND + "\n"); report.append("Device: " + Build.DEVICE + "\n"); report.append("Display: " + Build.DISPLAY + "\n"); report.append("Finger Print: " + Build.FINGERPRINT + "\n"); report.append("Host: " + Build.HOST + "\n"); report.append("ID: " + Build.ID + "\n"); report.append("Product: " + Build.PRODUCT + "\n"); report.append("Tags: " + Build.TAGS + "\n"); report.append("Time: " + Build.TIME + "\n"); report.append("Type: " + Build.TYPE + "\n"); report.append("User: " + Build.USER + "\n"); report.append("Configuration: " + config + "\n"); report.append("Screen Layout: size " + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long " + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n"); report.append("Display Metrics: " + res.getDisplayMetrics() + "\n"); report.append(/*from www. j av a2 s. co m*/ "Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass() + (activityManager.isLowRamDevice() ? " (low RAM device)" : "") + "\n"); report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n"); report.append("Bluetooth MAC: " + bluetoothMac() + "\n"); report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ") .append(System.getProperty("java.vm.version")).append("\n"); }
From source file:com.ericsun.duom.Framework.Activity.BaseActivity.java
/** * app???/*from w w w.j a va 2s. com*/ * * @return */ public boolean isAppOnForeground() { // Returns a list of application processes that are running on the // device ActivityManager activityManager = (ActivityManager) getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); String packageName = getApplicationContext().getPackageName(); List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); if (appProcesses == null) return false; for (RunningAppProcessInfo appProcess : appProcesses) { // The name of the process that this object is associated with. if (appProcess.processName.equals(packageName) && appProcess.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { return true; } } return false; }
From source file:org.peercast.core.PeerCastServiceController.java
/** * ??PeerCast??OS?????true//from w w w . java2 s . c om * * @return */ public boolean isServiceRunning() { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> services = activityManager.getRunningServices(256); for (RunningServiceInfo info : services) { if (CLASS_NAME_PEERCAST_SERVICE.equals(info.service.getClassName())) { return true; } } return false; }
From source file:com.nextgis.maplibui.service.WalkEditService.java
public static boolean isServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) if (WalkEditService.class.getName().equals(service.service.getClassName())) return true; return false; }
From source file:com.android.together.BaseActivity.java
/** * push /*from ww w.ja v a2 s . c o m*/ */ private boolean isPushRunning() { // TODO Auto-generated method stub ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> serviceList = mActivityManager.getRunningServices(Integer.MAX_VALUE); for (RunningServiceInfo info : serviceList) { if (Constant.NAME_PUSH_SERVICE.equals(info.service.getClassName())) { return true; } } return false; }
From source file:com.farmerbb.secondscreen.util.U.java
public static String uiRefreshCommand2(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); // For better reliability, we execute the UI refresh while on the home screen Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME); homeIntent.addCategory(Intent.CATEGORY_DEFAULT); homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(homeIntent);//from ww w . ja va 2 s.c om // Kill all background processes, in order to fully refresh UI PackageManager pm = context.getPackageManager(); List<ApplicationInfo> packages = pm.getInstalledApplications(0); for (ApplicationInfo packageInfo : packages) { if (!packageInfo.packageName.equalsIgnoreCase(context.getPackageName())) am.killBackgroundProcesses(packageInfo.packageName); } // Get launcher package name final ResolveInfo mInfo = pm.resolveActivity(homeIntent, 0); return "sleep 1 && am force-stop " + mInfo.activityInfo.applicationInfo.packageName; }