How to use Toast when I cant use "this" as context

Seth Hikari picture Seth Hikari · Apr 12, 2011 · Viewed 37.6k times · Source

I have a location listener activity and I want to make toast notifications. But it will not let me pass this as the context. How should I make toast work?

Answer

MByD picture MByD · Apr 12, 2011

If the toast is located inside your activity class, you could use YourActiviy.this where YourActivity is the class name. If it's outside your class, you'll need to get your activity context (pass it in the constructor etc).