Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android解析图像的URI_Android_Url_Uri - Fatal编程技术网

android解析图像的URI

android解析图像的URI,android,url,uri,Android,Url,Uri,我在网上发现了一些代码块,其中代码片段的主要目的是获取res文件夹中的图像URI,但当我将代码更改为我的应用程序路径时……应用程序崩溃了!我知道解决办法很简单,但很棘手,所以请帮助我 这里是方法 public static SkyBox getSkyBox1() { try { return new SkyBox(new URI[]{ URI.create("com.habie.a3d_model/res/drawable/ri

我在网上发现了一些代码块,其中代码片段的主要目的是获取res文件夹中的图像URI,但当我将代码更改为我的应用程序路径时……应用程序崩溃了!我知道解决办法很简单,但很棘手,所以请帮助我 这里是方法

 public static SkyBox getSkyBox1() {
    try {
        return new SkyBox(new URI[]{
                URI.create("com.habie.a3d_model/res/drawable/right.png"),
                URI.create("com.habie.a3d_model/res/drawable/left.png"),
                URI.create("com.habie.a3d_modelres/drawable/top.png"),
                URI.create("com.habie.a3d_model/res/drawable/bottom.png"),
                URI.create("com.habie.a3d_model/res/drawable/front.png"),
                URI.create("com.habie.a3d_model/res/drawable/back.png")});



    } catch (IOException e) {
        throw new RuntimeException(e);

这些是我想要使用的图像….

您的URI没有定义任何方案。尝试更改为:

URI.create("android.resource://com.habie.a3d_model/res/drawable/right.png")
请看这里:

那太酷了!但是URI没有.parse方法,我想..那太酷了!但是URI没有.parse方法,我想..对不起,我没有注意到您正在使用
java.net.URI
。参考代码是针对android.net.Uri的。只要用create替换parse,它就可以工作了。或者您可以使用android.net.Uri