Demo entry 6745365

   

Submitted by anonymous on May 27, 2018 at 02:53
Language: Java. Code size: 1.3 kB.

private void initDataSize(final CacheInfo cacheInfo, final int position)
	{
		try
		{
			Method method = PackageManager.class.getMethod(
					"getPackageSizeInfo", new Class[] { String.class,
							IPackageStatsObserver.class });
			method.invoke(packageManager,
					new Object[] { cacheInfo.getPackageName(),
							new IPackageStatsObserver.Stub()
							{
								@Override
								public void onGetStatsCompleted(
										PackageStats pStats, boolean succeeded)
										throws RemoteException
								{
									System.out.println("onGetStatsCompleted" + position);
									long cacheSize = pStats.cacheSize;
									long codeSize = pStats.codeSize;
									long dataSize = pStats.dataSize;

									cacheInfo.setCacheSize(TextFormater
											.dataSizeFormat(cacheSize));
									cacheInfo.setCodeSize(TextFormater
											.dataSizeFormat(codeSize));
									cacheInfo.setDataSize(TextFormater
											.dataSizeFormat(dataSize));

									cacheInfos.add(cacheInfo);

									if (position == (size - 1))
									{
										// 当完全获取完信息之后,发送一个成功的消息
										// 1对应的就是CacheClearActivity里面的FINISH
										handler.sendEmptyMessage(1);
									}
								}
							} });
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).