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.gm.goldencity.util.Utils.java
public static String getFrontPackageName(Context ctx) { ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> processes = activityManager.getRunningAppProcesses(); return processes.get(0).processName; }
From source file:com.gm.goldencity.util.Utils.java
public static boolean isMyServiceRunning(Context ctx, String serviceClassName) { final ActivityManager activityManager = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RunningServiceInfo> services = activityManager .getRunningServices(Integer.MAX_VALUE); for (ActivityManager.RunningServiceInfo runningServiceInfo : services) { if (runningServiceInfo.service.getClassName().equalsIgnoreCase(serviceClassName)) { return true; }/*from ww w. j a va2 s .co m*/ } return false; }
From source file:com.keithandthegirl.ui.activity.EpisodesFragment.java
/** * Determines if the MediaPlayerService is already running. * /*from ww w . j a v a 2 s .c om*/ * @return true if the service is running, false otherwise. */ private boolean MediaPlayerServiceRunning() { //Log.v( TAG, "MediaPlayerServiceRunning : enter" ); ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { //Log.v( TAG, "MediaPlayerServiceRunning : service=" + service.service.getClassName() ); if ("com.keithandthegirl.services.playback.MediaPlayerService".equals(service.service.getClassName())) { //Log.v( TAG, "MediaPlayerServiceRunning : exit, MediaPlayerService is running" ); return true; } } //Log.v( TAG, "MediaPlayerServiceRunning : exit, MediaPlayerService is NOT running" ); return false; }
From source file:com.fastbootmobile.encore.utils.Utils.java
public static String getAppNameByPID(Context context, int pid) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) { if (processInfo.pid == pid) { return processInfo.processName; }/* w w w .j av a2 s .co m*/ } return ""; }
From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java
private boolean isMyServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (BatchDownloaderService.class.getName().equals(service.service.getClassName())) { return true; }/*from ww w . j ava 2 s . c o m*/ } Log.i("Service not", "running"); return false; }
From source file:ti.modules.titanium.android.AndroidModule.java
@Kroll.method public boolean isServiceRunning(IntentProxy intentProxy) { Intent intent = intentProxy.getIntent(); if (intent == null) { Log.w(TAG, "isServiceRunning called with empty intent. Will return false, but value is meaningless."); return false; }/*from ww w. j a va2s . c o m*/ TiApplication app = TiApplication.getInstance(); if (app == null) { Log.w(TAG, "Application instance is no longer available. Unable to check isServiceRunning. Returning false though value is meaningless."); return false; } ActivityManager am = (ActivityManager) app.getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); if (am != null) { List<RunningServiceInfo> services = am.getRunningServices(Integer.MAX_VALUE); for (RunningServiceInfo service : services) { if (service.service.equals(intent.getComponent())) { return true; } } } return false; }
From source file:com.radiusnetworks.scavengerhunt.ScavengerHuntApplication.java
public static boolean isApplicationSentToBackground(final Context context) { if (context != null) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> tasks = am.getRunningTasks(1); if (!tasks.isEmpty()) { ComponentName topActivity = tasks.get(0).topActivity; if (!topActivity.getPackageName().equals(context.getPackageName())) { return true; }/* w w w. j a va 2 s. c o m*/ } } return false; }
From source file:com.geniusgithub.contact.common.ContactPhotoManager.java
public ContactPhotoManagerImpl(Context context) { mContext = context;//from w w w .jav a 2 s . c om final ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)); final float cacheSizeAdjustment = (am.isLowRamDevice()) ? 0.5f : 1.0f; final int bitmapCacheSize = (int) (cacheSizeAdjustment * BITMAP_CACHE_SIZE); mBitmapCache = new LruCache<Object, Bitmap>(bitmapCacheSize) { @Override protected int sizeOf(Object key, Bitmap value) { return value.getByteCount(); } @Override protected void entryRemoved(boolean evicted, Object key, Bitmap oldValue, Bitmap newValue) { if (DEBUG) dumpStats(); } }; final int holderCacheSize = (int) (cacheSizeAdjustment * HOLDER_CACHE_SIZE); mBitmapHolderCache = new LruCache<Object, BitmapHolder>(holderCacheSize) { @Override protected int sizeOf(Object key, BitmapHolder value) { return value.bytes != null ? value.bytes.length : 0; } @Override protected void entryRemoved(boolean evicted, Object key, BitmapHolder oldValue, BitmapHolder newValue) { if (DEBUG) dumpStats(); } }; mBitmapHolderCacheRedZoneBytes = (int) (holderCacheSize * 0.75); Log.i(TAG, "Cache adj: " + cacheSizeAdjustment); if (DEBUG) { Log.d(TAG, "Cache size: " + btk(mBitmapHolderCache.maxSize()) + " + " + btk(mBitmapCache.maxSize())); } mThumbnailSize = context.getResources().getDimensionPixelSize(R.dimen.contact_browser_list_item_photo_size); }
From source file:com.silentcircle.contacts.ContactPhotoManagerNew.java
@TargetApi(Build.VERSION_CODES.KITKAT) public ContactPhotoManagerImplNew(Context context) { mContext = context;/*from w w w .j a va 2s . c o m*/ final ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)); final float cacheSizeAdjustment = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) ? (am.isLowRamDevice() ? 0.5f : 1.0f) : 0.5f; final int bitmapCacheSize = (int) (cacheSizeAdjustment * BITMAP_CACHE_SIZE); mBitmapCache = new LruCache<Object, Bitmap>(bitmapCacheSize) { @Override protected int sizeOf(Object key, Bitmap value) { return value.getByteCount(); } @Override protected void entryRemoved(boolean evicted, Object key, Bitmap oldValue, Bitmap newValue) { if (DEBUG) dumpStats(); } }; final int holderCacheSize = (int) (cacheSizeAdjustment * HOLDER_CACHE_SIZE); mBitmapHolderCache = new LruCache<Object, BitmapHolder>(holderCacheSize) { @Override protected int sizeOf(Object key, BitmapHolder value) { return value.bytes != null ? value.bytes.length : 0; } @Override protected void entryRemoved(boolean evicted, Object key, BitmapHolder oldValue, BitmapHolder newValue) { if (DEBUG) dumpStats(); } }; mBitmapHolderCacheRedZoneBytes = (int) (holderCacheSize * 0.75); if (DEBUG) { Log.i(TAG, "Cache adj: " + cacheSizeAdjustment); Log.d(TAG, "Cache size: " + btk(mBitmapHolderCache.maxSize()) + " + " + btk(mBitmapCache.maxSize())); } mThumbnailSize = context.getResources().getDimensionPixelSize(R.dimen.contact_browser_list_item_photo_size); }
From source file:com.android.contacts.common.ContactPhotoManager.java
public ContactPhotoManagerImpl(Context context) { mContext = context;//from ww w .j a v a 2s. co m final ActivityManager am = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)); final float cacheSizeAdjustment = (am.isLowRamDevice()) ? 0.5f : 1.0f; final int bitmapCacheSize = (int) (cacheSizeAdjustment * BITMAP_CACHE_SIZE); mBitmapCache = new LruCache<Object, Bitmap>(bitmapCacheSize) { @Override protected int sizeOf(Object key, Bitmap value) { return value.getByteCount(); } @Override protected void entryRemoved(boolean evicted, Object key, Bitmap oldValue, Bitmap newValue) { if (DEBUG) dumpStats(); } }; final int holderCacheSize = (int) (cacheSizeAdjustment * HOLDER_CACHE_SIZE); mBitmapHolderCache = new LruCache<Object, BitmapHolder>(holderCacheSize) { @Override protected int sizeOf(Object key, BitmapHolder value) { return value.bytes != null ? value.bytes.length : 0; } @Override protected void entryRemoved(boolean evicted, Object key, BitmapHolder oldValue, BitmapHolder newValue) { if (DEBUG) dumpStats(); } }; mBitmapHolderCacheRedZoneBytes = (int) (holderCacheSize * 0.75); Log.i(TAG, "Cache adj: " + cacheSizeAdjustment); if (DEBUG) { Log.d(TAG, "Cache size: " + btk(mBitmapHolderCache.maxSize()) + " + " + btk(mBitmapCache.maxSize())); } mThumbnailSize = context.getResources().getDimensionPixelSize(R.dimen.contact_browser_list_item_photo_size); // Get a user agent string to use for URI photo requests. mUserAgent = UserAgentGenerator.getUserAgent(context); if (mUserAgent == null) { mUserAgent = ""; } }