• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PackageStats类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.content.pm.PackageStats的典型用法代码示例。如果您正苦于以下问题:Java PackageStats类的具体用法?Java PackageStats怎么用?Java PackageStats使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PackageStats类属于android.content.pm包,在下文中一共展示了PackageStats类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
        public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
            String packageName = pStats.packageName;
            long cacheSize = pStats.cacheSize;
            long codeSize = pStats.codeSize;
            long dataSize = pStats.dataSize;
            cacheS += cacheSize;
//            sb.delete(0, sb.length());
            if (cacheSize > 0) {
                sb.append("")
                        .append("")
                        .append("")
                        .append("")
                ;

                //Log.e("aaaa", sb.toString());
            }

        }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:20,代码来源:MainActivity.java


示例2: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
        throws RemoteException {
    //获取缓存
    long cache = pStats.cacheSize;
    if(cache>0){
        try {
            CacheInfo cacheInfo = new CacheInfo();
            PackageManager pm = getPackageManager();
            //添加缓存信息到ui界面
            //获取包名
            cacheInfo.packname = pStats.packageName;
            PackageInfo packInfo = pm.getPackageInfo(cacheInfo.packname, 0);
            cacheInfo.cachesize = cache;
            cacheInfo.appname = packInfo.applicationInfo.loadLabel(pm).toString();
            cacheInfo.icon = packInfo.applicationInfo.loadIcon(pm);
            Message msg = Message.obtain();
            msg.obj = cacheInfo;
            handler.sendMessage(msg);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:25,代码来源:CleanCacheActivity.java


示例3: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
		throws RemoteException {
	long cacheSize = pStats.cacheSize;
	if (cacheSize > 0) {
		CacheInfo cacheInfo = new CacheInfo();
		String appName = packageInfo.applicationInfo.loadLabel(pm)
				.toString();
		if (appName.isEmpty()) {
			cacheInfo.appName = packageInfo.packageName;
		} else {
			cacheInfo.appName = appName;
		}
		Drawable icon = packageInfo.applicationInfo.loadIcon(pm);
		if (icon == null) {
			cacheInfo.icon = getResources().getDrawable(
					R.drawable.ic_launcher);
		} else {
			cacheInfo.icon = icon;
		}
		cacheInfo.cacheSize = cacheSize;
		cacheInfos.add(cacheInfo);
	}
}
 
开发者ID:yoxin,项目名称:safety,代码行数:25,代码来源:CleanCacheActivity.java


示例4: getAppList

import android.content.pm.PackageStats; //导入依赖的package包/类
/**
 * 返回用户已安装应用列表
 */
public List<ApkModel> getAppList(Context context) {
    PackageManager pm = context.getPackageManager();
    List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
    List<ApkModel> appInfos = new ArrayList<>();
    for (PackageInfo packageInfo : packageInfos) {
        ApplicationInfo app = packageInfo.applicationInfo;
        if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            // 非系统应用
            PackageStats stats = new PackageStats(packageInfo.packageName);
            ApkModel appInfo = new ApkModel();
            appInfo.packageName = packageInfo.packageName;
            appInfo.versionCode = packageInfo.versionCode;
            appInfo.versionName = packageInfo.versionName;
            appInfo.icon = app.loadIcon(pm);
            appInfo.name = app.loadLabel(pm).toString();
            appInfo.cacheSize = stats.cacheSize;
            appInfo.dataSize = stats.dataSize;
            appInfos.add(appInfo);
        }
    }
    return appInfos;
}
 
开发者ID:hanks-zyh,项目名称:apkInstaller,代码行数:26,代码来源:MainActivity.java


示例5: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
/*** �ص������� 
 * @param pStatus ,�������ݷ�װ��PackageStats������ 
 * @param succeeded  ����ص��ɹ� 
 */   
@Override  
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)  
        throws RemoteException {  
    cachesize = pStats.cacheSize  ; //�����С  
    datasize = pStats.dataSize  ;  //���ݴ�С   
    codesize = pStats.codeSize  ;  //Ӧ�ó����С  
    totalsize = cachesize + datasize + codesize ;              
    Log.i(TAG, "cachesize--->"+cachesize+" datasize---->"+datasize+ " codeSize---->"+codesize); 
    Log.i(TAG, "Ŀǰ���߳�����" + Thread.currentThread().getName());
    // ��ȡ��������ʾAlertDialog
    // ���Եõ�����δ�����߳���Binder_1,2,3�����ȣ�����Ҫ�������̵߳���showAlertDialog()
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            showAlertDialog();
        }
    });
}
 
开发者ID:loveNight,项目名称:AppInfo,代码行数:23,代码来源:ListAppActivity.java


示例6: setAppSize

import android.content.pm.PackageStats; //导入依赖的package包/类
/**
 * 根据包名获取应用程序的体积信息 注意: 这个方法是一个异步的方法 程序的体积要花一定时间才能获取到.
 * 
 * @param packname
 */
private void setAppSize(final String packname) {
	try {
		Method method = PackageManager.class.getMethod("getPackageSizeInfo", new Class[] { String.class, IPackageStatsObserver.class });
		method.invoke(getPackageManager(), new Object[] { packname, new IPackageStatsObserver.Stub() {

			public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
				// 注意这个操作是一个异步的操作
				long codesize = pStats.codeSize;
				long datasize = pStats.dataSize;
				Logger.i(TAG, packname);
				CacheInfo info = maps.get(packname);
				info.setDataSize(Formatter.formatFileSize(mApp, datasize));
				info.setCodeSize(Formatter.formatFileSize(mApp, codesize));
				maps.put(packname, info);
			}
		} });
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:bingoogolapple,项目名称:Graduation-Design,代码行数:26,代码来源:OptimizeActivity.java


示例7: onTransact

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
        throws RemoteException {
    switch (code) {
        case INTERFACE_TRANSACTION: {
            reply.writeString(DESCRIPTOR);
            return true;
        }
        case FIRST_CALL_TRANSACTION: {
            data.enforceInterface(DESCRIPTOR);
            final PackageStats _arg0;
            if ((0 != data.readInt())) {
                _arg0 = PackageStats.CREATOR.createFromParcel(data);
            } else {
                _arg0 = null;
            }
            final boolean _arg1 = (0 != data.readInt());
            this.onGetStatsCompleted(_arg0, _arg1);
            return true;
        }
    }
    return true;
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:23,代码来源:PackageStatsObserver.java


示例8: FileSystemPackage

import android.content.pm.PackageStats; //导入依赖的package包/类
public FileSystemPackage(
    String name, String pkg, PackageStats stats,
    int flags, Long hackApkSize, int blockSize) {
  super(null, name);
  this.pkg = pkg;
  this.cacheSize = stats.cacheSize;
  this.dataSize = stats.dataSize;
  this.flags = flags | (hackApkSize != null ? SDCARD_FLAG : 0);
  this.dalvikCacheSize = guessDalvikCacheSize();
  if (onSD()) {
    if (hackApkSize != null) {
      this.codeSize = hackApkSize.intValue();
    } else {
      this.codeSize = stats.codeSize;
    }
  } else {
    this.codeSize = stats.codeSize - this.dalvikCacheSize;
  }
}
 
开发者ID:IvanVolosyuk,项目名称:DiskUsage.0,代码行数:20,代码来源:FileSystemPackage.java


示例9: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onGetStatsCompleted(PackageStats packageStats, boolean succeeded)
		throws RemoteException {
	mScanCount++;
	if (packageStats == null || !succeeded) {
	} else {
		mCallBack.onScanProgress((int)(mScanCount * 100 / mTotalCount));
		CacheInfo cacheInfo = new CacheInfo();
		cacheInfo.setPackageName(packageStats.packageName);
		cacheInfo.setCacheSize(packageStats.cacheSize);
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
			cacheInfo.setCacheSize(packageStats.cacheSize + packageStats.externalCacheSize);
		}
		cacheInfo.setChecked(true);
		
		ArrayList<CacheInfo> caches = CacheLab.get(mAppContext).getCaches();
		if (cacheInfo.getCacheSize() != 0) {
			caches.add(cacheInfo);
		}
	}
	if (mScanCount == mTotalCount) {
		mCallBack.onScanFinish();
	}
}
 
开发者ID:mzlogin,项目名称:AndroidPractices,代码行数:26,代码来源:CacheScanTask.java


示例10: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
public void onGetStatsCompleted( PackageStats pStats, boolean succeeded )
		throws RemoteException
{
	AppInfoHolder holder = appCache.appLookup.get( pStats.packageName );

	if ( holder != null )
	{
		synchronized ( appCache )
		{
			holder.size = Formatter.formatFileSize( ac, pStats.codeSize )
					+ " + " //$NON-NLS-1$
					+ Formatter.formatFileSize( ac, pStats.dataSize )
					+ " (" //$NON-NLS-1$
					+ Formatter.formatFileSize( ac, pStats.cacheSize )
					+ ')';

			holder.codeSize = pStats.codeSize;
			holder.dataSize = pStats.dataSize;
			holder.cacheSize = pStats.cacheSize;
		}
	}

	count.countDown( );
}
 
开发者ID:qauck,项目名称:qsysinfo,代码行数:25,代码来源:ApplicationManager.java


示例11: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {

    long cacheSize = pStats.cacheSize;//得到缓存大小

    if (cacheSize > 0) {//没有缓存的就不处理了

        String appName = installPackage.applicationInfo.loadLabel(packageManager).toString();//得到应用名称

        Drawable icon = installPackage.applicationInfo.loadIcon(packageManager);//得到应用LOGO

        String packageName = installPackage.applicationInfo.packageName;//应用包名

        CacheInfos cacheInfo = new CacheInfos(cacheSize, appName, packageName, icon);

        cacheInfos.add(cacheInfo);//增加到集合中
    }
}
 
开发者ID:paifeng,项目名称:Mobile-guards,代码行数:19,代码来源:CacheClearActivity.java


示例12: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
        public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
            String packageName = pStats.packageName;
            long cacheSize = pStats.cacheSize;
            long codeSize = pStats.codeSize;
            long dataSize = pStats.dataSize;
//            sb.delete(0, sb.length());
            if (cacheSize > 0) {

	    }

        }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:13,代码来源:AnimatedEditText.java


示例13: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
        public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
            String packageName = pStats.packageName;
            long cacheSize = pStats.cacheSize;
            long codeSize = pStats.codeSize;
            long dataSize = pStats.dataSize;
//            sb.delete(0, sb.length());
            if (cacheSize > 0) {
		
	    }

        }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:13,代码来源:dex_smali.java


示例14: getPackageInfo

import android.content.pm.PackageStats; //导入依赖的package包/类
private void getPackageInfo(Context context, String pkg) {
    PackageManager pm = context.getPackageManager();
    try {
        Method method_getPackageSizeInfo = pm.getClass().getMethod("getPackageSizeInfo", String.class, IPackageStatsObserver.class);
        method_getPackageSizeInfo.invoke(pm, pkg, new IPackageStatsObserver.Stub() {

            @Override
            public IBinder asBinder() {
                log.d("asBinder");
                return super.asBinder();
            }

            @Override
            public void onGetStatsCompleted(PackageStats packageStats, boolean b) throws RemoteException {
                final StringBuilder sb = new StringBuilder("onGetStatsCompleted\n");
                sb.append("packageName:").append(packageStats.packageName).append("\n");
                sb.append("cacheSize:").append(packageStats.cacheSize).append("\n");
                sb.append("dataSize:").append(packageStats.dataSize).append("\n");
                sb.append("externalDataSize:").append(packageStats.externalDataSize).append("\n");
                log.i(sb.toString());
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        mDataBinding.txtContent.setText(sb);
                    }
                });

            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:vipycm,项目名称:mao-android,代码行数:34,代码来源:PmFragment.java


示例15: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override
public void onGetStatsCompleted(PackageStats pStats,boolean successd) throws RemoteException {
    long cachesize = pStats.cacheSize;
    if (cachesize >= 0) {
        CacheInfo cacheinfo = new CacheInfo();
        cacheinfo.setPackagename(info.packageName);
        cacheinfo.setCachesize(cachesize);
        cacheinfo.setAppname(info.applicationInfo.loadLabel(packageManager).toString());
        cacheinfo.setAppicon(info.applicationInfo.loadIcon(packageManager));
        cacheInfos.add(cacheinfo);
        cacheMemory += cachesize;
    }
}
 
开发者ID:sh2zqp,项目名称:MobilePhoneSafeProtector,代码行数:14,代码来源:CacheClearListActivity.java


示例16: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
public void onGetStatsCompleted(PackageStats stats, boolean succeeded) {
        	long cachesize = stats.cacheSize;//缓存大小
        	/*long codesize = stats.codeSize;//应用程序的大小
        	long datasize = stats.dataSize;//数据大小
*/        	if (cachesize > 0) {
					String cache = Formatter.formatFileSize(ClearCacheActivity.this, cachesize);
					list.add(new CachInfo(stats.packageName, cache));
			}
        	/*String code = Formatter.formatFileSize(getActivity(), codesize);
        	String data = Formatter.formatFileSize(getActivity(), datasize);*/
//        	System.out.println(stats.packageName+"cachesize:"+cache +" codesize:"+code+" datasize:"+data);
        }
 
开发者ID:liaozhoubei,项目名称:EndCallAndClearCacheDemo,代码行数:13,代码来源:ClearCacheActivity.java


示例17: getAppSize

import android.content.pm.PackageStats; //导入依赖的package包/类
/**
 * get app size by package name
 * @param context
 * @param packageName package name
 * @param listener it will be call when success to get size
 */
public static void getAppSize(Context context, String packageName, final AppSizeInfoListener listener) {
    // check argument
    if(null == listener) {
        throw new NullPointerException("listener can't be null");
    }
    if(TextUtils.isEmpty(packageName)) {
        throw  new IllegalArgumentException("packageName can't be empty");
    }

    // get pm
    PackageManager pm = context.getPackageManager();
    Method getPackageSizeInfo = null;
    try {
        // get method getPackageSizeInfo
        getPackageSizeInfo = pm.getClass().getMethod(
                "getPackageSizeInfo",
                String.class, IPackageStatsObserver.class);
        // call method
        getPackageSizeInfo.invoke(pm, packageName,
                new IPackageStatsObserver.Stub() {
                    @Override
                    public void onGetStatsCompleted(PackageStats pStats, boolean succeeded)
                            throws RemoteException {
                        // call listener
                        listener.onGetSizeInfoCompleted(
                                new AppSizeInfo(pStats.cacheSize, pStats.dataSize, pStats.codeSize));
                    }
                });
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
开发者ID:ittianyu,项目名称:MobileGuard,代码行数:40,代码来源:AppManagerEngine.java


示例18: getAppList

import android.content.pm.PackageStats; //导入依赖的package包/类
/**
 * 返回用户已安装应用列表
 */
public static List<AppEntity> getAppList(Context context) {
    PackageManager pm = context.getPackageManager();
    List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
    List<AppEntity> appInfos = new ArrayList<AppEntity>();
    for (PackageInfo packageInfo : packageInfos) {

        ApplicationInfo app = packageInfo.applicationInfo;
        if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
            // 非系统应用
            File apkfile = new File(app.sourceDir);
            PackageStats stats = new PackageStats(packageInfo.packageName);
            AppEntity appInfo = new AppEntity(app.sourceDir);
            appInfo.setPackageName(packageInfo.packageName);
            appInfo.setVersionCode(packageInfo.versionCode);
            appInfo.setVersionName(packageInfo.versionName);
            appInfo.setUid(app.uid);
            appInfo.setIcon(app.loadIcon(pm));
            appInfo.setAppName(app.loadLabel(pm).toString());
            appInfo.setCacheSize(stats.cacheSize);
            appInfo.setDataSize(stats.dataSize);
            appInfos.add(appInfo);
        }

    }

    return appInfos;
}
 
开发者ID:hanks-zyh,项目名称:FlyWoo,代码行数:31,代码来源:AppUtils.java


示例19: getPkgSize

import android.content.pm.PackageStats; //导入依赖的package包/类
public static long getPkgSize(final Context context, String pkgName) throws NoSuchMethodException,
            InvocationTargetException,
            IllegalAccessException {
       long pkgSize=0;
        // getPackageSizeInfo是PackageManager中的一个private方法,所以需要通过反射的机制来调用
        Method method = PackageManager.class.getMethod("getPackageSizeInfo",
                new Class[]{String.class, IPackageStatsObserver.class});
        // 调用 getPackageSizeInfo 方法,需要两个参数:1、需要检测的应用包名;2、回调
        method.invoke(context.getPackageManager(), new Object[]{
                pkgName,
                new IPackageStatsObserver.Stub() {
                    @Override
                    public void onGetStatsCompleted(PackageStats pStats, boolean succeeded) throws RemoteException {
                        // 子线程中默认无法处理消息循环,自然也就不能显示Toast,所以需要手动Looper一下
                        Looper.prepare();
                        // 从pStats中提取各个所需数据


                      //  pkgSize= pStats.cacheSize+pStats.dataSize+pStats.codeSize;
//                        Toast.makeText(context,
//                                "缓存大小=" + Formatter.formatFileSize(context, pStats.cacheSize) +
//                                        "\n数据大小=" + Formatter.formatFileSize(context, pStats.dataSize) +
//                                        "\n程序大小=" + Formatter.formatFileSize(context, pStats.codeSize),
//                                Toast.LENGTH_LONG).show();
                        // 遍历一次消息队列,弹出Toast
                        Looper.loop();
                    }
                }
        });

        return pkgSize;
    }
 
开发者ID:KouChengjian,项目名称:PhoneMate,代码行数:33,代码来源:Utils.java


示例20: onGetStatsCompleted

import android.content.pm.PackageStats; //导入依赖的package包/类
@Override public void onGetStatsCompleted(final PackageStats pStats, final boolean success) throws RemoteException {
    Timber.v("onGetStatsCompleted(): %s", success);
    App.HANDLER.post(new Runnable() {
        @Override
        public void run() {
            packageStatsListener.onPackageStats(pStats);
        }
    });
}
 
开发者ID:amartinz,项目名称:DeviceControl,代码行数:10,代码来源:PackageStatsObserver.java



注:本文中的android.content.pm.PackageStats类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MergingLexerAdapter类代码示例发布时间:2022-05-21
下一篇:
Java TextPipe类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap