AlertDialog cannot be shown from ListActivity within ActivityGroup?

Got it! Actually here it's an Android Context problem.

Got it! Actually here it's an Android Context problem. In line: AlertDialog.

Builder builder = new AlertDialog. Builder(this); Instead of this, you should pass the Context of the TabActivity, the context of the visible/main activity is passed to display any popup within activity. So, simple solution: Store context of TabActivity for later use in pop-up.

Pass TabActivity Context in pop-up code instead of this. Hope this helps. Cheers :).

Ok, I think I've implemented your suggestion by putting public static MyActivity context; in the TabActivity class, setting context = this; in the onCreate method, and then passing MyActivity. Context when creating the dialog builder. Is that the right idea?

This seems to have fixed the problem in any case. I find it odd that passing this works within the ListActivity but not when in the ActivityGroup, even though both are under the TabActivity. – GJP Feb 5 '11 at 7:12 .

Great to know you solved! Now mark this Answer as CORRECT so it may be useful to others. – piyushnp Feb 5 '11 at 7:47 1 good answer it works for me.

Thnx – Sumant Jun 20 '11 at 11:52.

I just want to chime in and say that the above answer did not reliably work for me (when I'd resume the whole app I'd see the same old crash). What did work was using the parent context instead. See also: how to show alert inside an activity group?

Seems that this is the correct approach. Thanks :) – Dommel Sep 13 '11 at 3:34.

Finally followed your approach and solved my problem. Here I am giving some details create a context to the Tabactivity class as follows. "public static MyTabactivity context;" assgin "context= this" in onCreate method of the MyTabactivity.

Then use MyTabactivity. Context in your alertboxes as follows. "AlertDialog.

Builder adb =new AlertDialog. Builder(MyTabactivity. Context);" I hope this will help.....

To make it fairly simple, instead of defining context variable and setting it on onCreate, what you can do is you can directly pass getParent() as context in the alertDialog.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions