User Tools

Site Tools


android:tips

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
android:tips [2017/02/14 10:43] – [Assets] orelandroid: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 "SDL_system.h"+#include "SDL_system.h"  // TRY DONT USE THIS
 #include <jni.h> #include <jni.h>
 #include <android/asset_manager.h> #include <android/asset_manager.h>
Line 14: Line 14:
  
 // retrieve the JNI environment. // retrieve the JNI environment.
-JNIEnv* jnienv = (JNIEnv*)SDL_AndroidGetJNIEnv();+JNIEnv* jnienv = (JNIEnv*)SDL_AndroidGetJNIEnv();   // REPLACE THIS
 int version = (*jnienv)->GetVersion(jnienv); int version = (*jnienv)->GetVersion(jnienv);
-SDL_Log("version %d\n", version);+// SDL_Log("version %d\n", version);
  
 // retrieve the Java instance of the SDLActivity // retrieve the Java instance of the SDLActivity
-jobject activity = (jobject)SDL_AndroidGetActivity();+jobject activity = (jobject)SDL_AndroidGetActivity();  // REPLACE THIS
  
 // 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 on +// 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, filename, AASSET_MODE_STREAMING); 
 +  char buf[BUFSIZ]; 
 +  int nb_read = 0; 
 +  FILE* out = fopen(filename, "w"); 
 +  while ((nb_read = AAsset_read(asset, buf, BUFSIZ)) > 0) 
 +    fwrite(buf, nb_read, 1, out); 
 +  fclose(out); 
 +  AAsset_close(asset); 
 +
 +AAssetDir_close(assetDir); 
          
 // env->DeleteLocalRef(activity); // env->DeleteLocalRef(activity);
android/tips.1487069014.txt.gz · Last modified: 2024/03/18 15:04 (external edit)