在android中是什么意思,它是如何工作的? [英] What is the meaning of URI in android and how does it work?

查看:94
本文介绍了在android中是什么意思,它是如何工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对uri感到很困惑,我根本没有得到uri的概念。我在网上研究过,我真的很困惑。我正在阅读wrox android编程书,他们提到了以下代码,我不明白uri.parse()方法的作用。



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.

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





//什么角色uri.parse()在上面的代码中做了什么?



我也见过这样的东西uri.parse(http://www.google.com )....这是什么意思?



我非常困惑,有人可以用简单的语言解释我uri的概念是什么,解析是什么方法吗?



//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?

推荐答案

在Android中,这意味着一个URI,统一资源标识符 [ ^ ] .Android API包含以下定义: , Uri [ android.net 中的http://developer.android.com/reference/android/net/Uri.htmltarget =_ blanktitle =新窗口> ^ ]包。



但......你的代码中的一个看起来不像那样,Java是一种区分大小写的语言,所以Uri不等于uri。它们具有不同的含义,并且由于parse是一个静态函数,因此您的代码将无法编译。请将其更改为



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

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





你必须保留名称原样,否则会导致代码出现问题。我希望代码可以正常工作(如果 edittext1 定义为写入另外,阅读所提供的资源以了解有关Uri或其他对象的更多信息。您将在官方Android文档中找到更多资源,请访问它们。:)



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. :)


这篇关于在android中是什么意思,它是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆