private Listener listener;
private boolean audioDisabled = false;
- public AndroidAudioRenderer(Activity context) {
+ public AndroidAudioRenderer(Context context) {
this.context = context;
manager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
- context.setVolumeControlStream(AudioManager.STREAM_MUSIC);
+ if (context instanceof Activity) {
+ ((Activity)context).setVolumeControlStream(AudioManager.STREAM_MUSIC);
+ }
am = context.getAssets();
}
import android.opengl.GLES20;
import android.os.Build;
import com.jme3.app.AndroidHarness;
+import com.jme3.app.Application;
import com.jme3.asset.AssetManager;
import com.jme3.asset.DesktopAssetManager;
import com.jme3.asset.TextureKey;
*/
GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, intBuf16);
maxTexSize = intBuf16.get(0);
- logger.log(Level.INFO, "Maximum Texture Resolution: {0}", maxTexSize);
+ logger.log(Level.INFO, "Maximum Texture Resolution: {0}"+ maxTexSize);
GLES20.glGetIntegerv(GLES20.GL_MAX_CUBE_MAP_TEXTURE_SIZE, intBuf16);
maxCubeTexSize = intBuf16.get(0);
if ( bmp.isRecycled() )
{
// We need to reload the bitmap
- DesktopAssetManager assetManager = (DesktopAssetManager)((AndroidHarness)JmeSystem.getActivity()).getJmeApplication().getAssetManager();
+ DesktopAssetManager assetManager;
+ try {
+ assetManager = (DesktopAssetManager)((AndroidHarness)JmeSystem.getActivity()).getJmeApplication().getAssetManager();
+ } catch(ClassCastException ex) {
+ Application app = JmeSystem.getApplication();
+ assetManager = (DesktopAssetManager) app.getAssetManager();
+ }
assetManager.deleteFromCache((TextureKey)tex.getKey());
Texture textureReloaded = assetManager.loadTexture((TextureKey)tex.getKey());
image.setEfficentData( textureReloaded.getImage().getEfficentData());
package com.jme3.system;\r
\r
import android.app.Activity;\r
+import android.content.Context;\r
import android.content.res.Resources;\r
+import com.jme3.app.Application;\r
import com.jme3.util.AndroidLogHandler;\r
import com.jme3.asset.AndroidAssetManager;\r
import com.jme3.asset.AssetManager;\r
private static boolean initialized = false;\r
private static boolean lowPermissions = false;\r
private static Resources res;\r
- private static Activity activity;\r
+ private static Context activity;\r
+ private static ThreadLocal<Application> app = new ThreadLocal<Application>();\r
\r
public static void initialize(AppSettings settings) {\r
if (initialized) {\r
\r
public static JmeContext newContext(AppSettings settings, Type contextType) {\r
initialize(settings);\r
+ if (settings.getRenderer().startsWith("LiveWallpaper")) {\r
+ \r
+ }\r
return new OGLESContext();\r
}\r
\r
return res;\r
}\r
\r
- public static void setActivity(Activity activity) {\r
+ public static void setActivity(Context activity) {\r
JmeSystem.activity = activity;\r
+ \r
+ }\r
+ public static void setApplication(Application app) {\r
+ JmeSystem.app.set(app);\r
+ }\r
+ public static Application getApplication() {\r
+ return app.get();\r
}\r
\r
- public static Activity getActivity() {\r
+ public static Context getActivity() {\r
return activity;\r
}\r
\r
public void destroy(boolean waitFor)
{
needClose.set(true);
- if (waitFor)
+ if (waitFor) {
waitFor(false);
+ } else {
+ listener.destroy();
+ listener = null;
+ }
}
public void destroy()