Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Testing and Debugging Making a Toast

Mit Sengupta
Mit Sengupta
13,823 Points

Can anyone please help me sorting out what is wrong here?

I just did how it was up on the video, the same way.

ToastTest.java
Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();

1 Answer

That could be perfect, but what is this inside? The first parameter is this, which is the context. If "this" isn't enough to get to the correct context, you may need more detail, such as the class name of the activity (MainActivity.class) or a different context. This happens a lot when the context you're in is an anonymous class, such as a Callback or an OnClickListener.

I also noticed that this is a treehouse test. Is the text you are supposed to toast exactly the same as they ask for in the question, capitalization and punctuation included?

Mit Sengupta
Mit Sengupta
13,823 Points

Thanks for your answer. I have just figured it out and it's solved now. They want us do the static method first and then the one line code.