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 trialChris Collins
2,490 PointsOpening a Webpage Within the App code challenge part 3
hey guys, heres the question
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.
and here is what i have done so far
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;
import android.webkit.WebView;
public class WebViewActivity extends Activity {
protected String mUrl;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
WebView webView = (WebView) findViewById(R.id.webView1);
Intent intent = getIntent();
Uri blogUri = intent.getData();
}
}
im not really sure how to store blogUri in mUrl can anyone point me in the right direction?
1 Answer
Ben Jakuben
Treehouse TeacherYou are so close! Just one more step and you're done. mUrl
is a String variable (see its declaration above the onCreate()
method). blogUri
is being set property as a Uri
object. So all you need to do is convert blogUri
to a String and set that as the value for mUrl
.
In Java, you can very often use a method called toString()
to convert an object into a String representation of it. It doesn't work for everything, but why don't you see what happens when you call toString()
on the blogUri
variable?
Chris Collins
2,490 PointsChris Collins
2,490 Pointsthanks ben
looking forward to the android Build a Self-Destructing Message App
:)
Brian Chewning
7,270 PointsBrian Chewning
7,270 PointsI am unable to figure out what i am doing wrong,
} what am I missing?
Brian Chewning
7,270 PointsBrian Chewning
7,270 PointsNever mind I got it.