android:tips
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| android:tips [2017/02/14 10:41] – created 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 45: | Line 45: | ||
| // SDL_Log(" | // SDL_Log(" | ||
| - | | + | /* Use either AAsset_read or AAsset_getBuffer. */ |
| + | |||
| + | // 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-> | ||
| Line 55: | Line 72: | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| + | * https:// | ||
| * https:// | * https:// | ||
android/tips.1487068909.txt.gz · Last modified: 2024/03/18 15:04 (external edit)
