> I deal with these situations by just keeping a public static reference
> around to the currently active activity. E.g.

Brilliant idea!!!  That's the solution!

And you could abstract it out into a sub class like this (I wish
showDialog/dismissDialog weren't marked as final!):

public class OrientationAwareActivity extends Activity {
        private static OrientationAwareActivity ACTIVE_INSTANCE;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                ACTIVE_INSTANCE = this;
        }

        @Override
        protected void onDestroy() {
                super.onDestroy();

                ACTIVE_INSTANCE = null;
        }

        public void showDialogSmart(int id) {
                if (ACTIVE_INSTANCE != null) {
                        ACTIVE_INSTANCE.showDialog(id);
                }
        }

        public void dismissDialogSmart(int id) {
                if (ACTIVE_INSTANCE != null) {
                        ACTIVE_INSTANCE.dismissDialog(id);
                }
        }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to