title: Can't access AAssetManager in native code passed from Java in WallpaperService
body: <p>I'm trying to access the the assets in native code from a custom WallpaperService.  The native code compiles and works but trying to get the AAssetManager reference from the AssetManager object passed to the native function always returns NULL.</p>
  
  <p>Is it something to do with the fact that I am using a Service rather than an Activity that results in the AAssetManager reference being NULL?  In the Java source the AssetManager being passed to the native function is valid and is not null.</p>
  
  <p>To test this I used them CubeLiveWallpaper demo from the samples provided and targeting API level 10. Here is the relevant code added to the CubeWallpaper1 class in order to access the native functionality:</p>
  
  <pre><code>static {
      System.loadLibrary("renderer");
  }
  
  private static native void load(AssetManager mgr);
  
  @Override
  public void onCreate() {
      super.onCreate();
  
      AssetManager mgr = getResources().getAssets();
      load(mgr);
  }
  </code></pre>
  
  <p>Here is the JNI code I'm using to try and acquire a valid AAssetManager reference:</p>
  
  <pre><code>#include &lt;jni.h&gt;
  #include &lt;android/log.h&gt;
  #include &lt;android/asset_manager.h&gt;
  #include &lt;android/asset_manager_jni.h&gt;
  
  #define TAG "CubeWallpaper1.c"
  
  void
  Java_com_example_android_livecubes_cube1_CubeWallpaper1_load(JNIEnv *env,
                                                               jobject assetManager) {
  
      AAssetManager *mgr = AAssetManager_fromJava(env, assetManager);
      if (mgr == NULL) {
          __android_log_print(ANDROID_LOG_ERROR, "CubeWallpaper1.c", "error loading asset   maanger");
      } else {
          __android_log_print(ANDROID_LOG_VERBOSE, "CubeWallpaper1.c", "loaded asset  manager");
      }
  
  }
  </code></pre>
  
  <p>This has been replicated on a couple of devices but most testing has been done on a HTC Desire running 2.3.7.</p>