private static final int DLG_CONFIRM_KILL_STORAGE_USERS = 1;
private static final int DLG_ERROR_SHARING = 2;
static final boolean localLOGV = false;
+ private boolean mDestroyed;
// UI thread
private Handler mUIHandler;
mProgressBar = (ProgressBar) findViewById(com.android.internal.R.id.progress);
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mDestroyed = true;
+ }
+
private void switchDisplay(final boolean usbStorageInUse) {
mUIHandler.post(new Runnable() {
@Override
return null;
}
- private void showDialogInner(int id) {
- removeDialog(id);
- showDialog(id);
+ private void scheduleShowDialog(final int id) {
+ mUIHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ if (!mDestroyed) {
+ removeDialog(id);
+ showDialog(id);
+ }
+ }
+ });
}
private void switchUsbMassStorage(final boolean on) {
IMountService ims = getMountService();
if (ims == null) {
// Display error dialog
- showDialogInner(DLG_ERROR_SHARING);
+ scheduleShowDialog(DLG_ERROR_SHARING);
}
String extStoragePath = Environment.getExternalStorageDirectory().toString();
boolean showDialog = false;
}
} catch (RemoteException e) {
// Display error dialog
- showDialogInner(DLG_ERROR_SHARING);
+ scheduleShowDialog(DLG_ERROR_SHARING);
}
if (showDialog) {
// Display dialog to user
- showDialogInner(DLG_CONFIRM_KILL_STORAGE_USERS);
+ scheduleShowDialog(DLG_CONFIRM_KILL_STORAGE_USERS);
} else {
if (localLOGV) Log.i(TAG, "Enabling UMS");
switchUsbMassStorage(true);