I am implementing android application for getting All applications and Running applications and their sizes, usage and CPU usage.
But i'm only get the all and running applications Icon, Label and Packegename not able to retrieve sizes, usage and CPU usage.
I saw an application in GooglePlayStore that is AndroidSystem Info. In that app all system information given.
I want to retrieve that information programmatically.
Can anyone please help me to get total system information
thanks in advance.................
Here is my code:
For getting All Applications:
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
PackageManager pm = getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);
ApplicationInfo entry = (ApplicationInfo) mListAppInfo.get(position);
ImageView ivAppIcon = (ImageView) v.findViewById(R.id.ivIcon);
TextView tvAppName = (TextView) v.findViewById(R.id.tvName);
TextView tvPkgName = (TextView) v.findViewById(R.id.tvPack);
// set data to display
ivAppIcon.setImageDrawable(entry.loadIcon(mPackManager));
tvAppName.setText(entry.loadLabel(mPackManager));
tvPkgName.setText(entry.packageName);
For Getting Running Applications
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runAppList = am.getRunningAppProcesses();
int listsize = runAppList.size();
Log.v("tag", "listsize..." + listsize);
You can Do this using IPackageStatsObserver.aidl interface. Create package android.content.pm in your app src directory and Implement below code It will return all appliscation size.
Method getPackageSizedInfo =pm.getClass().getMethod("getPackageSizeInfo",String.class,IPackageStatsObserver.class);
getPackageSizedInfo.invoke(pm, pkgname,new IPackageStatsObserver.Stub() {
@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)throws RemoteException {double size=(double)pStats.codeSize+pStats.cacheSize+pStats.dataSize;}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With