Search in sources :

Example 71 with ActivityManager

use of android.app.ActivityManager in project CloudReader by youlookwhat.

the class BaseTools method getTopActivityName.

/**
     * 处于栈顶的Activity名
     */
public String getTopActivityName(Context context) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List var2 = am.getRunningTasks(1);
    return ((ActivityManager.RunningTaskInfo) var2.get(0)).topActivity.getClassName();
}
Also used : List(java.util.List) ActivityManager(android.app.ActivityManager)

Example 72 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ResurrectionRemix.

the class DocumentsApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final int memoryClassBytes = am.getMemoryClass() * 1024 * 1024;
    mRoots = new RootsCache(this);
    mRoots.updateAsync(false);
    mThumbnails = new ThumbnailCache(memoryClassBytes / 4);
    final IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
    packageFilter.addDataScheme("package");
    registerReceiver(mCacheReceiver, packageFilter);
    final IntentFilter localeFilter = new IntentFilter();
    localeFilter.addAction(Intent.ACTION_LOCALE_CHANGED);
    registerReceiver(mCacheReceiver, localeFilter);
}
Also used : IntentFilter(android.content.IntentFilter) ActivityManager(android.app.ActivityManager) Point(android.graphics.Point)

Example 73 with ActivityManager

use of android.app.ActivityManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class RunningProcessesView method doCreate.

public void doCreate() {
    mAm = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);
    mState = RunningState.getInstance(getContext());
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.running_processes_view, this);
    mListView = (ListView) findViewById(android.R.id.list);
    View emptyView = findViewById(com.android.internal.R.id.empty);
    if (emptyView != null) {
        mListView.setEmptyView(emptyView);
    }
    mListView.setOnItemClickListener(this);
    mListView.setRecyclerListener(this);
    mAdapter = new ServiceListAdapter(mState);
    mListView.setAdapter(mAdapter);
    mHeader = inflater.inflate(R.layout.running_processes_header, null);
    mListView.addHeaderView(mHeader, null, false);
    mColorBar = (LinearColorBar) mHeader.findViewById(R.id.color_bar);
    final Context context = getContext();
    mColorBar.setColors(context.getColor(R.color.running_processes_system_ram), Utils.getColorAccent(context), context.getColor(R.color.running_processes_free_ram));
    mBackgroundProcessPrefix = (TextView) mHeader.findViewById(R.id.freeSizePrefix);
    mAppsProcessPrefix = (TextView) mHeader.findViewById(R.id.appsSizePrefix);
    mForegroundProcessPrefix = (TextView) mHeader.findViewById(R.id.systemSizePrefix);
    mBackgroundProcessText = (TextView) mHeader.findViewById(R.id.freeSize);
    mAppsProcessText = (TextView) mHeader.findViewById(R.id.appsSize);
    mForegroundProcessText = (TextView) mHeader.findViewById(R.id.systemSize);
    ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
    mAm.getMemoryInfo(memInfo);
    SECONDARY_SERVER_MEM = memInfo.secondaryServerThreshold;
}
Also used : Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) ActivityManager(android.app.ActivityManager) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 74 with ActivityManager

use of android.app.ActivityManager in project android_frameworks_base by ResurrectionRemix.

the class GLDepthTestActivity method detectOpenGLES20.

private boolean detectOpenGLES20() {
    ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    ConfigurationInfo info = am.getDeviceConfigurationInfo();
    return (info.reqGlEsVersion >= 0x20000);
}
Also used : ActivityManager(android.app.ActivityManager) ConfigurationInfo(android.content.pm.ConfigurationInfo)

Example 75 with ActivityManager

use of android.app.ActivityManager in project ride-read-android by Ride-Read.

the class AppUtils method isServiceRunning.

/**
     * 判断Service是否running
     *
     * @param context
     * @param serviceClass
     * @return
     */
public static boolean isServiceRunning(Context context, Class<? extends Service> serviceClass) {
    try {
        context = context.getApplicationContext();
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningServiceInfo> serviceList = activityManager.getRunningServices(2000);
        for (ActivityManager.RunningServiceInfo info : serviceList) {
            String name = info.service.getClassName();
            if (name != null && name.contains(serviceClass.getName())) {
                return true;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
Also used : ActivityManager(android.app.ActivityManager)

Aggregations

ActivityManager (android.app.ActivityManager)339 Intent (android.content.Intent)44 Context (android.content.Context)33 RunningAppProcessInfo (android.app.ActivityManager.RunningAppProcessInfo)30 ComponentName (android.content.ComponentName)26 PackageManager (android.content.pm.PackageManager)23 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)18 IActivityManager (android.app.IActivityManager)16 ConfigurationInfo (android.content.pm.ConfigurationInfo)16 IOException (java.io.IOException)16 RunningServiceInfo (android.app.ActivityManager.RunningServiceInfo)15 View (android.view.View)15 ImageView (android.widget.ImageView)15 ArrayList (java.util.ArrayList)15 Point (android.graphics.Point)14 TextView (android.widget.TextView)14 RunningTaskInfo (android.app.ActivityManager.RunningTaskInfo)13 ResolveInfo (android.content.pm.ResolveInfo)12 RemoteException (android.os.RemoteException)12 TargetApi (android.annotation.TargetApi)11