Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am really confused about uri and i am not getting the concept of uri at all. I researched online and i am really getting confused. I am reading the wrox android programming book and they mentioned the following code and i dont understand the role of uri.parse() method.

Java
Intent intent = new Intent();
 intent.getdata(uri.parse(editext1.gettext().toString());


//what role does the uri.parse() do in the above code?

I have also seen something like this uri.parse("http://www.google.com")....what does it mean?

I am terribly confused and can someone explain me in simple terms what is the concept of uri and what does the parse method do?
Posted

1 solution

In Android that means a URI, Uniform Resource Identifier[^]. The Android API contains the definition as, Uri[^] in android.net package.

But... The one in your code doesn't look like that, Java is a case-sensitive language, so Uri is not equal to uri. They have different meanings, and since parse is a static function, your code won't compile. Please change it to

Java
// Changed 
//    1. getdata to getData
//    2. uri to Uri
//    3. gettext to getText
Intent intent = new Intent();
intent.getData(Uri.parse(editext1.getText().toString());


You must keep the names as they are, otherwise they will cause a problem in your code. I hope the code would work (if edittext1 is defined as it is written). Plus, read the resources provided to learn more about Uri or other objects. You will find a lot of more resources on official Android documentation, do visit them. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900