Black screen error in LIBGDX + Android

Anything libgdx related goes here!

Black screen error in LIBGDX + Android

Postby MMM1412 » Sun Jul 17, 2016 2:25 pm

Im trying to take image from android gallery and add it into my game.

I choose image from Gallery of Android by code: (open Andoid gallery)

Code: Select all
  Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            intent.setType("image/*");
                activity.startActivityForResult(Intent.createChooser(intent,"Choose Gallery App"), SELECT_IMAGE_CODE);
           


Everything work fine but sometimes my game auto change into black after i choose an image (all is black). But my game 's still open with admob banner at top, everything is black instead of running admob banner.

I think my game was dispose or could not resume when AndroidLauncher pause or stop (because there 's a other Android game or app (other activity) open above it ). Anybody have same problem ??
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Re: Black screen error in LIBGDX + Android

Postby MMM1412 » Sun Jul 17, 2016 4:28 pm

In brief, My game changes into all black instead of admob banner still is running at top. Anybody could tell me what problem is ???
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Re: Black screen error in LIBGDX + Android

Postby MMM1412 » Sat Sep 10, 2016 10:30 am

:oops: More some users give me 1* because my game turn into black after Interstitial was showed. Sometime Its happen when I open image Gallery or open Google Play .... in mygame. Not only Texture or TextureAtlas but also everything in my game were disposed (I tried to touch at positon of a Android-dialog button after my game change into black, and nothing happen--> my button was diposed too).

This is biggest problem I face from Libgdx. Most of mistakes in my game are from Android library. Hope Libgdx team could fix it in future. I think Libgdx team should focus on increasing stability of Libgdx. Stability is base of development.
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Re: Black screen error in LIBGDX + Android

Postby tomski » Sat Sep 10, 2016 10:57 am

There could be all sorts of reasons why this is happening, we don't have any code that reproduces your specific issue, so how can anyone help you? You have posted some android specific code that doesn't have anything to do with LibGDX.

Are your Textures static? If so, stop doing that, or learn to clean them up correctly. There are huge amount of resources available when you google "libgdx black textures", or "libgdx black on resume", so perhaps try there.

Without any further information about what you are doing specifically there is only guessing.
tomski
 
Posts: 913
Joined: Wed Jun 26, 2013 6:06 pm

Re: Black screen error in LIBGDX + Android

Postby MMM1412 » Sat Sep 10, 2016 12:37 pm

Sorry, but My game dont throw exceptions and there 's not crash report about this problem from user , just go black, ads still run. As I tell about my button on screen, if the problem 's just about Texture or Atlas, my button must be active there (must show an Android dialog even in black). I really dont want dispose all my game and recreate or reload all just because of opening an gallery app or showing interstitial (and there are image of player from gallery In my game ). Till now, this problem happen randomly, I will try to test my game again to find out problem and send them to you. But Reloading all assets or Recreating All game in resume() is just a provisional solution even it's efficient. Libgdx is very great, just improve it, please.
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Re: Black screen error in LIBGDX + Android

Postby kazi » Sat Sep 10, 2016 4:27 pm

Don't blame the engine for something that's entirely within your control.

Chances are, you're falling victim to Androids "JVM Recycle" lifecycle. On some types of game exit, the game exits, but the JVM does not. This resets all of the textures, but does not reload them, making all textures appear black. You need to forcibly reload your textures every time your game starts (typically in create()) to avoid this.
kazi
 
Posts: 20
Joined: Mon Dec 15, 2014 4:11 am

Re: Black screen error in LIBGDX + Android

Postby intrigus » Sat Sep 10, 2016 4:34 pm

Just don't use static AssetManagers, Textures or TextureAtlases.
intrigus
 
Posts: 89
Joined: Fri May 15, 2015 10:33 pm

Re: Black screen error in LIBGDX + Android

Postby MMM1412 » Wed Sep 14, 2016 8:35 am

Maybe i think too complicatedly about my problem. Thanks for answers. I will try to fix my game again. I have many plans with Libgdx. :D
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Re: Black screen error in LIBGDX + Android

Postby MMM1412 » Thu Sep 22, 2016 4:20 am

I do not use static textures, Atlas, or Asset manager. It happen more often in ver 1.9.4 and 1.9.3. After more a week my rating go down focus on Android 4.0.3 - 4.0.4 (black screen)and cant' open in android 6.0, i come back ver 1.9.2 and now my rating is increasing. Obviously, I should wait for 1.9.5. Just one plus then Libgdx will be perfect for me.
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Re: Black screen error in LIBGDX + Android

Postby MMM1412 » Thu Sep 22, 2016 11:05 am

Think again. Actually, I load all my assets from inside game except for one texture that i load from Android Gallery. Users could create their photo in game. Here is code i use to create Texture from a bitmap loaded from gallery App of Android.
Code: Select all
public class AndroidLauncher extends AndroidApplication implements IGoogleservice {

private Texture tex;
...

 private void Loadimagefromgallery(Uri data) throws IOException, NullPointerException {

        final Bitmap bitmap= Getbitmap.getImage(this, data, MAX, MAX);

 Gdx.app.postRunnable(new Runnable() {
        @Override
        public void run() {
          if (tex != null) {
                    tex.dispose();   
                    tex = null;
                }
          tex = new Texture(bitmap.getWidth(), bitmap.getHeight(), Format.RGBA8888);
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.getTextureObjectHandle());
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
          GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
          bitmap.recycle();
          Maingame.setphotoplayer(tex);
        }
      });

}


That could make all my game crash and change all into black ??? I'm not sure, anyone can help me ??
MMM1412
 
Posts: 119
Joined: Mon Sep 14, 2015 10:48 am

Next

Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest