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.ohso.util.ImageHandler.java
public ImageHandler(Activity activity) { MEMORY_CLASS = ((ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); MEMORY_CACHE_SIZE = 1024 * 1024 * MEMORY_CLASS / 8; // Use 1/8 the available memory mMemoryCache = new LruCache<String, Bitmap>(MEMORY_CACHE_SIZE) { protected int sizeOf(String key, Bitmap bitmap) { return bitmap.getRowBytes() * bitmap.getHeight(); }//from www . j a va 2s. com }; File cacheDir = new File(activity.getCacheDir(), "thumbnails"); try { mDiskCache = DiskLruCache.open(cacheDir, 1, 1, DISK_CACHE_SIZE); } catch (IOException e) { e.printStackTrace(); } mPixelSize = scaledDIP(IMAGE_DIMENSIONS); mPlaceholderParams = new RelativeLayout.LayoutParams((int) mPixelSize, (int) mPixelSize); mPlaceholderParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); mPlaceholderParams.topMargin = 0; }
From source file:net.bither.AndroidImplAbstractApp.java
@Override public ISetting initSetting() { return new ISetting() { @Override//w w w . j a v a 2 s . c om public BitherjSettings.AppMode getAppMode() { return AppSharedPreference.getInstance().getAppMode(); } @Override public boolean getBitherjDoneSyncFromSpv() { return AppSharedPreference.getInstance().getBitherjDoneSyncFromSpv(); } @Override public void setBitherjDoneSyncFromSpv(boolean isDone) { AppSharedPreference.getInstance().setBitherjDoneSyncFromSpv(isDone); } @Override public BitherjSettings.TransactionFeeMode getTransactionFeeMode() { return AppSharedPreference.getInstance().getTransactionFeeMode(); } @Override public BitherjSettings.ApiConfig getApiConfig() { return AppSharedPreference.getInstance().getApiConfig(); } @Override public File getPrivateDir(String dirName) { File file = BitherApplication.mContext.getDir(dirName, Context.MODE_PRIVATE); if (!file.exists()) { file.mkdirs(); } return file; } @Override public boolean isApplicationRunInForeground() { if (BitherApplication.mContext == null) { return false; } ActivityManager am = (ActivityManager) BitherApplication.mContext .getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1); if (tasks != null && !tasks.isEmpty()) { ComponentName topActivity = tasks.get(0).topActivity; if (!topActivity.getPackageName().equals(BitherApplication.mContext.getPackageName())) { return false; } } return true; } @Override public QRCodeUtil.QRQuality getQRQuality() { return AppSharedPreference.getInstance().getQRQuality(); } @Override public boolean getDownloadSpvFinish() { return AppSharedPreference.getInstance().getDownloadSpvFinish(); } @Override public void setDownloadSpvFinish(boolean finish) { AppSharedPreference.getInstance().setDownloadSpvFinish(finish); } @Override public CookieStore getCookieStore() { return PersistentCookieStore.getInstance(); } }; }
From source file:library.artaris.cn.library.utils.SystemUtils.java
/** * ??????//from w w w . j a v a2 s . com * @param context * @return */ public static boolean isBackground(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); for (RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.processName.equals(context.getPackageName())) { return appProcess.importance == RunningAppProcessInfo.IMPORTANCE_BACKGROUND; } } return false; }
From source file:org.wso2.emm.agent.api.RuntimeInfo.java
public Map<String, Application> getAppMemory() throws AndroidAgentException { Map<String, Application> applications = new HashMap<>(); Application appData;//from ww w . j a va 2 s . c om ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (String topCommandRow : topCommandRows) { if (topCommandRow != null && !topCommandRow.isEmpty() && !topCommandRow.contains(" root ")) { String[] columns = topCommandRow.replaceFirst("^\\s*", "").split(" "); String pidColumnValue = columns[0].trim(); if (!pidColumnValue.isEmpty() && TextUtils.isDigitsOnly(pidColumnValue)) { appData = new Application(); appData.setPackageName(columns[columns.length - 1]); int pid = Integer.parseInt(pidColumnValue); appData.setPid(Integer.parseInt(columns[0])); int totalPSS = activityManager.getProcessMemoryInfo(new int[] { pid })[0].getTotalPss(); appData.setPss(totalPSS); int totalPrivateDirty = activityManager.getProcessMemoryInfo(new int[] { pid })[0] .getTotalPrivateDirty(); appData.setUss(totalPrivateDirty); int totalSharedDirty = activityManager.getProcessMemoryInfo(new int[] { pid })[0] .getTotalSharedDirty(); appData.setSharedDirty(totalSharedDirty); applications.put(appData.getPackageName(), appData); } } } return applications; }
From source file:org.restcomm.app.utillib.Utils.Global.java
public static boolean isMainServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.cortxt.app.corelib.MainService".equals(service.service.getClassName())) { return true; }/* w w w. jav a 2 s. com*/ } return false; }
From source file:devicroft.burnboy.Activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initialiseAd();/*from www .ja v a2 s. c o m*/ setupFAB(); IntentFilter filter = new IntentFilter("devicroft.BurnBoy.CANCEL_NOTIFY"); this.registerReceiver(new NotificationCancelReceiver(), filter); if (getIntent().getAction() == Intent.ACTION_DELETE) { Intent intent = new Intent(); intent.setAction("devicroft.BurnBoy.CANCEL_NOTIFY"); intent.putExtra("id", NotificationCancelReceiver.NOTIFICATION_ID); sendBroadcast(intent); } ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (LogService.getName().equals(service.service.getClassName())) { Log.d(LOG_TAG, " REBIND on SERVICE"); Toast.makeText(this, "Still logging movement", Toast.LENGTH_SHORT); this.bindService(new Intent(this, LogService.class), serviceConnection, Context.BIND_AUTO_CREATE); } } TextView distance = (TextView) findViewById(R.id.distanceFocus); }
From source file:com.fallahpoor.infocenter.fragments.RamFragment.java
private String getFreeRam() { MemoryInfo memoryInfo;/*from w w w . j av a 2s . com*/ ActivityManager activityManager; long lngFreeRam; String freeRam; activityManager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); if (activityManager != null) { memoryInfo = new MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); lngFreeRam = memoryInfo.availMem; freeRam = Utils.getFormattedSize(lngFreeRam); } else { freeRam = getString(R.string.unknown); } return freeRam; }
From source file:com.prey.PreyPhone.java
@TargetApi(16) private void initMemory() { ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); MemoryInfo memoryInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo(memoryInfo); long totalMemory = totalMemory(); long freeMemory = memoryInfo.availMem / 1048576L; long usageMemory = totalMemory - freeMemory; hardware.setTotalMemory(totalMemory); hardware.setFreeMemory(totalMemory); hardware.setBusyMemory(usageMemory); }
From source file:com.neal.repairer.ease.receiver.CallReceiver.java
private boolean isRunningForeground(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; String currentPackageName = cn.getPackageName(); if (!TextUtils.isEmpty(currentPackageName) && currentPackageName.equals(context.getPackageName())) { return true; }/*w w w . j a va 2s. com*/ return false; }
From source file:com.example.finalfcm.MyFirebaseMessagingService.java
private boolean isAppIsInBackground(Context context) { boolean isInBackground = true; ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) { List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) { if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { for (String activeProcess : processInfo.pkgList) { if (activeProcess.equals(context.getPackageName())) { isInBackground = false; }// w w w . j ava 2 s. co m } } } } else { List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1); ComponentName componentInfo = taskInfo.get(0).topActivity; if (componentInfo.getPackageName().equals(context.getPackageName())) { isInBackground = false; } } return isInBackground; }