Android项目实战-手机卫士27-拿到余下内存以及正在运行的进程数

Android项目实战--手机卫士27--拿到剩余内存以及正在运行的进程数昨天, 我们已经把程序锁这个功能给完成了

Android项目实战--手机卫士27--拿到剩余内存以及正在运行的进程数

昨天, 我们已经把程序锁这个功能给完成了,那么今天,我们就来做一下进程管理的功能,其实就是通过一个ActivityManager的对象来获取到这些信息的,所以也是挺简单的。

那么我们现在就来写一下这些代码。

首先,我们先来回顾一下我们之前说的,自定义title,我们是通过隐藏系统自己的title,然后再布局文件里面增加一些控件来达到自定义title的作用的,那么今天我们就讲一下另一种自定义title的方式。


我们主要修改的也就是上面选定了的内容而已,所以我们现在在我们的style.xml里面写上几句样式

sytle.xml


好啦,上面的效果和我们隐藏自带的title, 然后自己用控件来实现差不多,大家可以根据自己的需要来选择实现方式


那么接下来,我们就要讲一下我们今天的主要内容啦,今天我们就是要把手机里面已经运行了的应用数目,以及手机里面剩余的内存数目啦

其实要拿到手机里面已经运行了的进程数目也很简单,只要我们拿到一个activityManager对象,然后再调用它的一个方法就可以的了

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="40dip"    android:gravity="center_vertical"    android:background="@drawable/title_background" >        <TextView         android:id="@+id/tv_process_count"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentLeft="true"        android:layout_marginLeft="10dip"        android:textColor="@android:color/white"        android:text="@string/process_count"/>        <TextView         android:id="@+id/tv_process_memory"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentRight="true"        android:layout_marginRight="10dip"        android:textColor="@android:color/white"        android:text="@string/process_memory"/></RelativeLayout>

好啦,今天就讲到这里啦,接下来,我们都会讲这个进程管理的内容的啦


最后,和大家说一下

为了方便大家的交流,我创建了一个群,这样子大家有什么疑问也可以在群上交流

群号是298440981



今天源码下载