Search in sources :

Example 1 with ActivityManager

use of android.app.ActivityManager in project packer-ng-plugin by mcxiaoke.

the class MainActivity method addDeviceInfoSection.

@SuppressLint("NewApi")
private void addDeviceInfoSection() {
    StringBuilder builder = new StringBuilder();
    builder.append("[Device]\n");
    ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    final MemoryInfo memoryInfo = new MemoryInfo();
    am.getMemoryInfo(memoryInfo);
    if (AndroidUtils.hasJellyBean()) {
        builder.append("Mem Total: ").append(StringUtils.getHumanReadableByteCount(memoryInfo.totalMem)).append("\n");
    }
    builder.append("Mem Free: ").append(StringUtils.getHumanReadableByteCount(memoryInfo.availMem)).append("\n");
    builder.append("Mem Heap: ").append(am.getMemoryClass()).append("M\n");
    builder.append("Mem Low: ").append(memoryInfo.lowMemory).append("\n");
    Display display = getWindowManager().getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    //DisplayMetrics dm = getResources().getDisplayMetrics();
    display.getMetrics(dm);
    int statusBarHeightDp = ViewUtils.getStatusBarHeightInDp(this);
    int systemBarHeightDp = ViewUtils.getSystemBarHeightInDp(this);
    int statusBarHeight = ViewUtils.getStatusBarHeight(this);
    int systemBarHeight = ViewUtils.getSystemBarHeight(this);
    Point point = getScreenRawSize(display);
    builder.append("statusBarHeightDp: ").append(statusBarHeightDp).append("\n");
    builder.append("systemBarHeightDp: ").append(systemBarHeightDp).append("\n");
    builder.append("statusBarHeightPx: ").append(statusBarHeight).append("\n");
    builder.append("systemBarHeightPx: ").append(systemBarHeight).append("\n");
    builder.append("screenWidth: ").append(point.x).append("\n");
    builder.append("screenHeight: ").append(point.y).append("\n");
    builder.append("WindowWidth: ").append(dm.widthPixels).append("\n");
    builder.append("WindowHeight: ").append(dm.heightPixels).append("\n");
    builder.append(toString2(dm));
    builder.append("\n");
    addSection(builder.toString());
}
Also used : MemoryInfo(android.app.ActivityManager.MemoryInfo) Point(android.graphics.Point) ActivityManager(android.app.ActivityManager) DisplayMetrics(android.util.DisplayMetrics) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Display(android.view.Display) SuppressLint(android.annotation.SuppressLint)

Example 2 with ActivityManager

use of android.app.ActivityManager in project AndroidTraining by mixi-inc.

the class DefaultModule method configure.

@SuppressWarnings("unchecked")
protected void configure() {
    bind(Application.class).toProvider(ApplicationProvider.class).in(ApplicationScoped.class);
    bind(Context.class).toProvider(ContextProvider.class);
    bind(Handler.class).toProvider(HandlerProvider.class).in(ApplicationScoped.class);
    bind(ActivityManager.class).toProvider(new SystemServiceProvider<ActivityManager>(Context.ACTIVITY_SERVICE));
    bind(AlarmManager.class).toProvider(new SystemServiceProvider<AlarmManager>(Context.ALARM_SERVICE));
    bind(AudioManager.class).toProvider(new SystemServiceProvider<AudioManager>(Context.AUDIO_SERVICE));
    bind(ConnectivityManager.class).toProvider(new SystemServiceProvider<ConnectivityManager>(Context.CONNECTIVITY_SERVICE));
    bind(InputMethodManager.class).toProvider(new SystemServiceProvider<InputMethodManager>(Context.INPUT_METHOD_SERVICE));
    bind(KeyguardManager.class).toProvider(new SystemServiceProvider<KeyguardManager>(Context.KEYGUARD_SERVICE));
    bind(LocationManager.class).toProvider(new SystemServiceProvider<LocationManager>(Context.LOCATION_SERVICE));
    bind(NotificationManager.class).toProvider(new SystemServiceProvider<NotificationManager>(Context.NOTIFICATION_SERVICE));
    bind(PowerManager.class).toProvider(new SystemServiceProvider<PowerManager>(Context.POWER_SERVICE));
    bind(SensorManager.class).toProvider(new SystemServiceProvider<SensorManager>(Context.SENSOR_SERVICE));
    bind(TelephonyManager.class).toProvider(new SystemServiceProvider<TelephonyManager>(Context.TELEPHONY_SERVICE));
    bind(Vibrator.class).toProvider(new SystemServiceProvider<Vibrator>(Context.VIBRATOR_SERVICE));
    bind(WifiManager.class).toProvider(new SystemServiceProvider<WifiManager>(Context.WIFI_SERVICE));
    bind(WindowManager.class).toProvider(new SystemServiceProvider<WindowManager>(Context.WINDOW_SERVICE));
    bind(mAccountManagerClass).toProvider(AccountManagerProvider.class);
    bind(ObserverManager.class);
    bindProviderListener(new ObserverRegister());
    bind(StateManager.class).in(ApplicationScoped.class);
    bind(StateEventObserver.class);
    bindFieldListener(RetainState.class, new RetainStateListener());
}
Also used : WifiManager(android.net.wifi.WifiManager) ConnectivityManager(android.net.ConnectivityManager) InputMethodManager(android.view.inputmethod.InputMethodManager) ActivityManager(android.app.ActivityManager) WindowManager(android.view.WindowManager) PowerManager(android.os.PowerManager) AudioManager(android.media.AudioManager) StateManager(proton.inject.state.StateManager) TelephonyManager(android.telephony.TelephonyManager) Context(android.content.Context) LocationManager(android.location.LocationManager) ApplicationProvider(proton.inject.provider.ApplicationProvider) NotificationManager(android.app.NotificationManager) HandlerProvider(proton.inject.provider.HandlerProvider) RetainStateListener(proton.inject.state.RetainStateListener) SensorManager(android.hardware.SensorManager) AlarmManager(android.app.AlarmManager) Vibrator(android.os.Vibrator) KeyguardManager(android.app.KeyguardManager) ObserverRegister(proton.inject.observer.ObserverRegister)

Example 3 with ActivityManager

use of android.app.ActivityManager in project okhttp-OkGo by jeasonlzy.

the class DownloadService method isServiceRunning.

public static boolean isServiceRunning(Context context) {
    boolean isRunning = false;
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningServiceInfo> serviceList = activityManager.getRunningServices(Integer.MAX_VALUE);
    if (serviceList == null || serviceList.size() == 0)
        return false;
    for (int i = 0; i < serviceList.size(); i++) {
        if (serviceList.get(i).service.getClassName().equals(DownloadService.class.getName())) {
            isRunning = true;
            break;
        }
    }
    return isRunning;
}
Also used : ActivityManager(android.app.ActivityManager)

Example 4 with ActivityManager

use of android.app.ActivityManager in project MVCHelper by LuckyJayce.

the class MyVolley method init.

public static void init(Context context) {
    mRequestQueue = Volley.newRequestQueue(context);
    int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    // Use 1/8th of the available memory for this memory cache.
    int cacheSize = 1024 * 1024 * memClass / 8;
    mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache(cacheSize));
}
Also used : ActivityManager(android.app.ActivityManager) ImageLoader(com.android.volley.toolbox.ImageLoader)

Example 5 with ActivityManager

use of android.app.ActivityManager in project actor-platform by actorapp.

the class ActorSDKApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    int id = android.os.Process.myPid();
    String myProcessName = getPackageName();
    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    for (ActivityManager.RunningAppProcessInfo procInfo : activityManager.getRunningAppProcesses()) {
        if (id == procInfo.pid) {
            myProcessName = procInfo.processName;
        }
    }
    // Protection on double start
    if (!myProcessName.endsWith(":actor_push")) {
        AndroidContext.setContext(this);
        onConfigureActorSDK();
        ActorSDK.sharedActor().createActor(this);
    }
}
Also used : ActivityManager(android.app.ActivityManager)

Aggregations

ActivityManager (android.app.ActivityManager)624 Intent (android.content.Intent)61 RunningAppProcessInfo (android.app.ActivityManager.RunningAppProcessInfo)55 PackageManager (android.content.pm.PackageManager)49 Context (android.content.Context)47 ComponentName (android.content.ComponentName)44 RunningServiceInfo (android.app.ActivityManager.RunningServiceInfo)38 ArrayList (java.util.ArrayList)33 View (android.view.View)29 IOException (java.io.IOException)29 SuppressLint (android.annotation.SuppressLint)27 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)27 ImageView (android.widget.ImageView)25 TextView (android.widget.TextView)25 IActivityManager (android.app.IActivityManager)19 ApplicationInfo (android.content.pm.ApplicationInfo)19 Point (android.graphics.Point)19 RemoteException (android.os.RemoteException)19 MemoryInfo (android.app.ActivityManager.MemoryInfo)18 Bitmap (android.graphics.Bitmap)18