- Home /
android app: load a local image into texture by WWW class
HELLO!
i make a android app that have to load a local image into texture.i can use WWW to load a url,but i can't use WWW to load a URi....
i use the following code to get android URi,and add my own intent fiter(action_send).when user open album,he can share the image to my app:
AndroidJavaObject activity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity");
AndroidJavaClass sintent = new AndroidJavaClass("android.content.Intent"); AndroidJavaObject intent = activity.Call("getIntent");
AndroidJavaObject uri = intent.Call("getParcelableExtra",sintent.GetStatic("EXTRA_STREAM"));
string appURL = uri.Call("toString");
i can receive a link like this:
content://media/external/images/media/47
but it seem that the WWW class don't know what is it.....
===edited====
i try to view the image Detail inside album,the image path is something like this:
/storage/sdcard0/Download/XXXXXX.JPG
i try to type this in to load the image: url="file://storage/sdcard0/Download/XXXXXX.JPG"; WWW www = new WWW(url); yield return www; plane.renderer.material.mainTexture = www.texture;
it still not working.....
and two type of link look very different:
file://storage/sdcard0/XXXXXXX.jpg content://media/external/images/media/47
but none of them work...........
i finally get this kind of link work: file://storage/sdcard0/XXXXXXX.jpg
but not this: content://media/external/images/media/47
i think the problem is HOW to convert content: to file,and that already off topic,sorry about that.