android:tips
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
android:tips [2017/02/14 10:43] – [Assets] orel | android:tips [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 8: | Line 8: | ||
<code C testasset.c> | <code C testasset.c> | ||
- | #include " | + | #include " |
#include < | #include < | ||
#include < | #include < | ||
Line 14: | Line 14: | ||
// retrieve the JNI environment. | // retrieve the JNI environment. | ||
- | JNIEnv* jnienv = (JNIEnv*)SDL_AndroidGetJNIEnv(); | + | JNIEnv* jnienv = (JNIEnv*)SDL_AndroidGetJNIEnv(); |
int version = (*jnienv)-> | int version = (*jnienv)-> | ||
- | SDL_Log(" | + | // SDL_Log(" |
// retrieve the Java instance of the SDLActivity | // retrieve the Java instance of the SDLActivity | ||
- | jobject activity = (jobject)SDL_AndroidGetActivity(); | + | jobject activity = (jobject)SDL_AndroidGetActivity(); |
// find the Java class of the activity. It should be SDLActivity or a subclass of it. | // find the Java class of the activity. It should be SDLActivity or a subclass of it. | ||
Line 47: | Line 47: | ||
/* Use either AAsset_read or AAsset_getBuffer. */ | /* Use either AAsset_read or AAsset_getBuffer. */ | ||
- | /* ADD SOMETHING TO COPY ALL ASSETS | + | // copy all files on local storage */ |
+ | |||
+ | AAssetDir* assetDir = AAssetManager_openDir(mgr, | ||
+ | const char* filename = (const char*)NULL; | ||
+ | while ((filename = AAssetDir_getNextFileName(assetDir)) != NULL) { | ||
+ | AAsset* asset = AAssetManager_open(mgr, | ||
+ | char buf[BUFSIZ]; | ||
+ | int nb_read = 0; | ||
+ | FILE* out = fopen(filename, | ||
+ | while ((nb_read = AAsset_read(asset, | ||
+ | fwrite(buf, nb_read, 1, out); | ||
+ | fclose(out); | ||
+ | AAsset_close(asset); | ||
+ | } | ||
+ | AAssetDir_close(assetDir); | ||
| | ||
// env-> | // env-> |
android/tips.1487069014.txt.gz · Last modified: 2024/03/18 15:04 (external edit)