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());
}
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());
}
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;
}
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));
}
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);
}
}
Aggregations