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 Blog Reader Android App Using Intents to Display and Share Posts Opening a Webpage Within the App

David Hope
David Hope
19,876 Points

Stuck on Challenge task 3 of 4.

"Now get the URI that you passed in as the data for the Intent. Convert it to a String URL and store it in the 'mUrl' member variable." I have tried every which way I can think of to do this, yet keep on getting this same message or a compiler error: "Don't forget to convert the Uri to a String and store it in the 'mUrl' member variable!"

The mUrl member variable is already pre-defined as a protected String, and all attempts to define it elsewhere have resulted in compiler errors.

Can someone please help or offer a hint as to what I'm doing wrong? Thanks in advance!

Intent intent = getIntent(); Uri mUrl = intent.getData();

    WebView webView = (WebView) findViewById(R.id.webView1);
    webView.loadUrl(mUrl.toString());

2 Answers

Daniel Hartin
Daniel Hartin
18,106 Points

Hi David

The challenge is asking you to define the mUrl string variable in the onCreate() method. Your Intent intent = getIntent(); line is correct. so directly under this line of code you should type the following:

mUrl = intent.getData().toString();

mUrl has already been defined above so just set it equal to intent(your variable name not the class name).getData() then chain the method .toString(); on the end to convert the getData method return value to a string.

Hope this helps

Daniel

David Hope
David Hope
19,876 Points

Thank you Daniel!!! Your solution and explanation were perfect. I hope to reach your high level of expertise in Android someday :) Take care and thank you again for your help Daniel! -David