Try/catch in update message dialog to fix crashes with trying to show with a non-running activity

pull/14/head
Sam Bosley 13 years ago
parent 14f8d81ae8
commit 06514f3a19

@ -14,6 +14,7 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;
import android.view.WindowManager.BadTokenException;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.Property.StringProperty;
@ -91,8 +92,20 @@ public class UpdateMessageService {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
DialogUtilities.htmlDialog(activity,
html, R.string.UpS_updates_title);
try {
DialogUtilities.htmlDialog(activity,
html, R.string.UpS_updates_title);
} catch (BadTokenException bt) {
try {
Activity current = (Activity) ContextManager.getContext();
DialogUtilities.htmlDialog(current,
html, R.string.UpS_updates_title);
} catch (ClassCastException c) {
// Oh well, context wasn't an activity
} catch (BadTokenException bt2) {
// Oh well, activity isn't running
}
}
}
});
}

Loading…
Cancel
Save