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.alphabetbloc.accessmrs.services.RefreshDataService.java
private boolean isUserEnteringData() { RunningAppProcessInfo currentApp = null; String accessFormsPackage = "com.alphabetbloc.accessforms"; boolean enteringData = false; ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List<RunningAppProcessInfo> l = am.getRunningAppProcesses(); Iterator<RunningAppProcessInfo> i = l.iterator(); while (i.hasNext()) { currentApp = i.next();// ww w. j av a 2 s . co m if (currentApp.processName.equalsIgnoreCase(accessFormsPackage)) { switch (currentApp.importance) { // case RunningAppProcessInfo.IMPORTANCE_FOREGROUND: case RunningAppProcessInfo.IMPORTANCE_VISIBLE: enteringData = true; break; default: enteringData = false; break; } } } return enteringData; }
From source file:com.pagenews.zhihudaily.homepage.MainActivity.java
@Override protected void onDestroy() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (CacheService.class.getName().equals(service.service.getClassName())) { stopService(new Intent(this, CacheService.class)); }/*from w ww. java 2 s . c o m*/ } super.onDestroy(); }
From source file:org.ambientdynamix.web.WebUtils.java
/** * Returns the RunningAppProcessInfo bound to the incoming socket. Returns null if the socket is not bound to any * apps./* ww w . j a v a 2s . c o m*/ */ public static RunningAppProcessInfo getAppProcessForSocket(Socket socket) { List<UidPortMapping> mappings = new ArrayList<WebUtils.UidPortMapping>(); // Check for connection type if (socket.getInetAddress() instanceof java.net.Inet4Address) { // Map all IPV4 connections mappings.addAll(getUidPortMappings("/proc/net/tcp")); } else { // Map all IPV6 connections mappings.addAll(getUidPortMappings("/proc/net/tcp6")); } // Create the local activity manager, if needed if (actMgr == null) { // Grab the ActivityManager actMgr = (ActivityManager) DynamixService.getAndroidContext() .getSystemService(Context.ACTIVITY_SERVICE); } /* * Loop through the list of running processes, looking for a UID matching one of the cached connections. */ List<RunningAppProcessInfo> l = actMgr.getRunningAppProcesses(); for (RunningAppProcessInfo app : l) { for (UidPortMapping connection : mappings) { if (connection.uid == app.uid) return app; } } Log.w(TAG, "Could not find RunningAppProcessInfo for socket " + socket); return null; }
From source file:count.ly.messaging.CrashDetails.java
/** * Returns the current device RAM amount. *//*from ww w .ja v a 2s .c o m*/ static String getRamCurrent(Context context) { ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo(); ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); activityManager.getMemoryInfo(mi); return Long.toString(getTotalRAM() - (mi.availMem / 1048576L)); }
From source file:com.odo.kcl.mobileminer.ProcSocketSet.java
public ProcSocketSet(Context ctx) { context = ctx;/*w w w . j a va2 s. c o m*/ processes = new ConcurrentHashMap<String, Process>(); am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); }
From source file:biz.wiz.android.wallet.WalletApplication.java
@Override public void onCreate() { new LinuxSecureRandom(); // init proper random number generator initLogging();/* ww w .j a va 2 s . c o m*/ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().permitDiskReads() .permitDiskWrites().penaltyLog().build()); Threading.throwOnLockCycles(); log.info("=== starting app using configuration: {}, {}", Constants.TEST ? "test" : "prod", Constants.NETWORK_PARAMETERS.getId()); super.onCreate(); packageInfo = packageInfoFromContext(this); CrashReporter.init(getCacheDir()); Threading.uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread thread, final Throwable throwable) { log.info("bitcoinj uncaught exception", throwable); CrashReporter.saveBackgroundTrace(throwable, packageInfo); } }; initMnemonicCode(); config = new Configuration(PreferenceManager.getDefaultSharedPreferences(this)); activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); blockchainServiceIntent = new Intent(this, BlockchainServiceImpl.class); blockchainServiceCancelCoinsReceivedIntent = new Intent(BlockchainService.ACTION_CANCEL_COINS_RECEIVED, null, this, BlockchainServiceImpl.class); blockchainServiceResetBlockchainIntent = new Intent(BlockchainService.ACTION_RESET_BLOCKCHAIN, null, this, BlockchainServiceImpl.class); walletFile = getFileStreamPath(Constants.Files.WALLET_FILENAME_PROTOBUF); loadWalletFromProtobuf(); config.updateLastVersionCode(packageInfo.versionCode); afterLoadWallet(); }
From source file:org.hopestarter.wallet.WalletApplication.java
@Override public void onCreate() { new LinuxSecureRandom(); // init proper random number generator initLogging();/* www. java 2s. c o m*/ getDefaultTracker(); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().permitDiskReads() .permitDiskWrites().penaltyLog().build()); Threading.throwOnLockCycles(); log.info("=== starting app using configuration: {}, {}", Constants.TEST ? "test" : "prod", Constants.NETWORK_PARAMETERS.getId()); super.onCreate(); mPackageInfo = packageInfoFromContext(this); CrashReporter.init(getCacheDir()); Threading.uncaughtExceptionHandler = new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(final Thread thread, final Throwable throwable) { log.info("bitcoinj uncaught exception", throwable); CrashReporter.saveBackgroundTrace(throwable, mPackageInfo); } }; initMnemonicCode(); initServerApi(); mConfig = new Configuration(PreferenceManager.getDefaultSharedPreferences(this), getResources()); mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); mBlockchainServiceIntent = new Intent(this, BlockchainServiceImpl.class); mBlockchainServiceCancelCoinsReceivedIntent = new Intent(BlockchainService.ACTION_CANCEL_COINS_RECEIVED, null, this, BlockchainServiceImpl.class); mBlockchainServiceResetBlockchainIntent = new Intent(BlockchainService.ACTION_RESET_BLOCKCHAIN, null, this, BlockchainServiceImpl.class); mWalletFile = getFileStreamPath(Constants.Files.WALLET_FILENAME_PROTOBUF); loadWalletFromProtobuf(); if (mConfig.versionCodeCrossed(mPackageInfo.versionCode, VERSION_CODE_SHOW_BACKUP_REMINDER) && !mWallet.getImportedKeys().isEmpty()) { log.info("showing backup reminder once, because of imported keys being present"); mConfig.armBackupReminder(); } mConfig.updateLastVersionCode(mPackageInfo.versionCode); mConfig.setExchangeCurrencyCode("EUR"); afterLoadWallet(); cleanupFiles(); }
From source file:com.andrewreitz.encryptedcamera.di.module.AndroidModule.java
@Provides
@Singleton
ActivityManager provideActivityManager() {
return (ActivityManager) application.getSystemService(Context.ACTIVITY_SERVICE);
}
From source file:com.wbtech.common.CommonUtil.java
/** * ??activity??/*www. j a v a 2 s . c om*/ * @param context * @return */ public static String getActivityName(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); if (checkPermissions(context, "android.permission.GET_TASKS")) { ComponentName cn = am.getRunningTasks(1).get(0).topActivity; return cn.getShortClassName(); } else { if (UmsConstants.DebugMode) { Log.e("lost permission", "android.permission.GET_TASKS"); } return null; } }
From source file:com.honkidenihongo.pre.service.JilFirebaseMessagingService.java
private boolean isAppRunning(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) { if (appProcess.processName.equals(context.getPackageName())) { if (appProcess.importance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_PERCEPTIBLE) { return true; }// w w w.java 2s.c o m } } return false; }