android why is TabActivity with Activity's crashing when open Dialog-Collection of common programming errors

I see there are like 10 answers for this question and i have read them all but cannot get this to work.

Im moving my activity’s into this TabGroup and I have 3 activity’s inside a tabgroup and got help doing it from here: Multiple Android Activities in a TabActivity

When opening a Custom Dialog i get this error:

07-12 10:07:56.985: ERROR/AndroidRuntime(9532): android.view.WindowManager$BadTokenException: Unable to add window — token android.app.LocalActivityManager$LocalActivityRecord@462d96f0 is not valid; is your activity running?

I know this error say that Context is bad.
On the ColorPickerView (belove) that dont work Im debugging and can see the Constructor doing it’s job but as soon as constructor finish it crashed.

The think is i got 3 similar error from the other two activity’s, one CheckBox, and two Spinner’s.
I could easily fix it by changing the Context appropriately .

This on is more complicated and the View stack looks like this

TabGroup …….TabHost (public class FileEditMainActivity extends Activity) ……………ImageView (public class FileEditImageView extends ImageView ) ……………………Dialog (public class ColorPickDialog extends Dialog )

…………………………View (private class ColorPickerView extends View )

No matter how i change the Context the system tells my that the Context is not alive.
The ColorPickerView is always crashing..

Must say also that this is working if i dont use the TabGroup. When I put the FileEditMainActivit in the TabGroup something goes wrong with the Context.
Anyone have an ide of what to do?

  1. Since everything is inside an ActivityGroup i hade to do like

    getparent().getParent()

    This might look brutal but it worked and for my level of experience im consider it to be a victory 🙂

    EDIT

    the line getparent().getParent() would be the context parameter, eg:

    final ProgressDialog dialog = ProgressDialog.show(this.getParent().getParent(), null, "Prcocessing", true, true);