URLs starting with "file:///android_res/raw" and relative paths seem to work only inside the WebView, not with the Javascript bridge in Wikitude SDK.
B
Bastiaan
said
over 9 years ago
I found that it's possible to load assets from your application project(which uses the library) within the library project. In the Android library I request the arview:
It loads the assets from the application project. The Wikitude SDK can load Images and Targets successfully this way from the application project.
I think for now, this is the best solution possible. I hope the information above may be of use for your team.
Thanks for your information.
G
Gabriele Boccone
said
over 9 years ago
Thank you for your information, I'm glad that it worked. I didn't know it could be implemented in that way.
Of course this will only work on Android, but I understand that you have no problems with cross-platform compatibility.
O
Oyindamola Oluwatimi
said
over 9 years ago
Hi. I 've been receiving an error. I know it is possible to load an image resource from the Android's application directory, but what do i pass as an argument?the abosulte path? E.g./ new AR.ImageResource("assets/marker_idle.png")
new AR.ImageDrawable(new AR.ImageResource("/data/data/com.example.myapp/files/image"), 2.5, {
zOrder: 0,
opacity: 1.0,
onClick: Marker.prototype.getOnClickTrigger(this)
});
I would like to download resources in the background and load it later when needed.
Thanks
Damola
G
Gabriele Boccone
said
over 9 years ago
The path is relative to the HTML file location (see SDK sample application).
If you need to load a file from the android assets directory, you can use the "file:///android_asset/" URL scheme.
O
Oyindamola Oluwatimi
said
over 9 years ago
I apologize for not being clear. When an Android application is installed, a set of folders are created under an apps data directory based on the app's namespace. E.g. SampleSDK app w/ namespace com.wikitiude.samplesSDK. The set of folders include
-cache
-files
-lib
-shared_prefs
Wikitude 3.2 states: "Images can be loaded from any source"
Since I need to load an image dynamically, I cannot retrieve it from the assets directory. I would download the file from a remote server onto the user's phone into the app's data directory. So my question is, how do I appropriately construct the string to retrieve a file in an app's data directory?
new AR.ImageResource("string/to/apps/data/diretory");
I hope the clarification helps. Thanks
G
Gabriele Boccone
said
over 9 years ago
Since your AR world is running inside a WebView, to acess absolute path you need to use a "file://" URL (e.g.: "file:///data/data/my.nice.app/cache/image/xyz")
However, you can load the images directly inside the AR World from a remote URL, they are cached internally and accessed dynamically when needed.
O
Oyindamola Oluwatimi
said
over 9 years ago
I've made much progress with your help. Thank you.
Now I'm attempting to test how many images I can load at one time. Unfortunately, I can only load just a few.
Specifically, when loading 5 files from the the "data/data" directory, only the first 3 appeared. If I switched to files from the "android_asset" directory and I could load more than 3.
Do you have any insight into what the problem might be?
G
Gabriele Boccone
said
over 9 years ago
There is a limit on the images you can download simultaneously, if that is what you mean.
Every image is downloaded in a separate thread, and maximal number of active threads is 4. If you start a new download when no threads are available, the request is put in a queue and waits for the first free slot.
Bastiaan