开发学院手机开发Android 开发 Android PendingIntent与Intent的区别的理解 阅读

Android PendingIntent与Intent的区别的理解

 2010-11-05 00:55:40 来源:WEB开发网   
核心提示:}registerReceiver(mClearCacheReceiver,new IntentFilter(ClearCacheReceiver.INTENT_CLEAR_CACHE));PendingIntent pi = PendingIntent.getBroadcast(this,0, new Intent(

}

registerReceiver(mClearCacheReceiver,

new IntentFilter(ClearCacheReceiver.INTENT_CLEAR_CACHE));

PendingIntent pi = PendingIntent.getBroadcast(this,

0, new Intent(ClearCacheReceiver.INTENT_CLEAR_CACHE), 0);

mPm.freeStorage(size, pi.getIntentSender());

}

private void checkOutOfSpace(long size) {

if(localLOGV) Log.i(TAG, "Checking for "+size+" number of bytes");

if (mClearCacheReceiver == null) {

mClearCacheReceiver = new ClearCacheReceiver();

}

registerReceiver(mClearCacheReceiver,

new IntentFilter(ClearCacheReceiver.INTENT_CLEAR_CACHE));

PendingIntent pi = PendingIntent.getBroadcast(this,

0, new Intent(ClearCacheReceiver.INTENT_CLEAR_CACHE), 0);

mPm.freeStorage(size, pi.getIntentSender());

}

以下是在PackageManagerService的:

Java代码

public void freeStorageAndNotify(final long freeStorageSize, final IPackageDataObserver observer) {

mContext.enforceCallingOrSelfPermission(

android.Manifest.permission.CLEAR_APP_CACHE, null);

// Queue up an async operation since clearing cache may take a little while.

mHandler.post(new Runnable() {

public void run() {

mHandler.removeCallbacks(this);

int retCode = -1;

if (mInstaller != null) {

retCode = mInstaller.freeCache(freeStorageSize);

if (retCode < 0) {

Slog.w(TAG, "Couldn't clear application caches");

}

} //end if mInstaller

if (observer != null) {

try {

observer.onRemoveCompleted(null, (retCode >= 0));

} catch (RemoteException e) {

Slog.w(TAG, "RemoveException when invoking call back");

}

}

}

});

}

Tags:Android PendingIntent Intent

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接