1

I found some block of code online,where the main aim of the snippet is to get image URI which is inside the res folder but when i changed the code to my apps path....the app crashes! I know the solution is simple n tricky,so please help me here is the method

 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);

these are the images i want to use them....

Habie
  • 52
  • 5

1 Answers1

1

Your URI doesn't have any scheme defined. Try changing to:

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

Take a look here: https://stackoverflow.com/a/6606163/14241710

Muhammad Faiq
  • 299
  • 2
  • 6
  • that would bre cool! But URI doesnt have .parse method i guess.. – Habie Mar 27 '21 at 07:03
  • that would bre cool! But URI doesnt have .parse method i guess.. – Habie Mar 27 '21 at 07:04
  • Sorry I didn't notice you are using the `java.net.URI`. The reference code is for `android.net.Uri`. Just replace parse with create and it should work. Or maybe you can use the `android.net.Uri` – Muhammad Faiq Mar 27 '21 at 07:20