1

What's the difference between myClass.this and getBaseContext? When I put an AlertDialog in a different class and instantiate it, I can only get the dialog to show if I use myClass.this from the parent class. I thought getBaseContext() did the same thing but I guess not. What am I missing?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
wufoo
  • 13,571
  • 12
  • 53
  • 78

2 Answers2

3

I believe you should look here first: Diffinitive rules for using Android's getBaseContext, getApplicationContext or using an Activity's “this”

Community
  • 1
  • 1
woodshy
  • 4,085
  • 3
  • 22
  • 21
0

"this" refers to what method you're in, and "getBaseContext/getApplicationContext" refers to the Activity you're in.

Tsunaze
  • 3,204
  • 7
  • 44
  • 81