Recalculate storage size in onStart rather than onCreate

Refresh the size info by invoking PackageManager API in onStart so that
the activity shows accurate storage information on being restarted.
This commit is contained in:
Suchi Amalapurapu
2009-04-07 14:22:58 -07:00
parent 741ce5855f
commit a5feaa76ef

View File

@@ -212,8 +212,6 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
totalSizeStr = appSizeStr = dataSizeStr = mComputingStr; totalSizeStr = appSizeStr = dataSizeStr = mComputingStr;
if(localLOGV) Log.i(TAG, "Have to compute package sizes"); if(localLOGV) Log.i(TAG, "Have to compute package sizes");
mSizeObserver = new PkgSizeObserver(); mSizeObserver = new PkgSizeObserver();
mPm.getPackageSizeInfo(packageName, mSizeObserver);
try { try {
mAppInfo = mPm.getApplicationInfo(packageName, mAppInfo = mPm.getApplicationInfo(packageName,
PackageManager.GET_UNINSTALLED_PACKAGES); PackageManager.GET_UNINSTALLED_PACKAGES);
@@ -290,6 +288,14 @@ public class InstalledAppDetails extends Activity implements View.OnClickListene
} }
} }
@Override
public void onStart() {
super.onStart();
if (mAppInfo != null && mAppInfo.packageName != null) {
mPm.getPackageSizeInfo(mAppInfo.packageName, mSizeObserver);
}
}
private void displayErrorDialog(int msgId, final boolean finish, final boolean changed) { private void displayErrorDialog(int msgId, final boolean finish, final boolean changed) {
//display confirmation dialog //display confirmation dialog
new AlertDialog.Builder(this) new AlertDialog.Builder(this)