Abhishek Sabbarwal
Abhishek Sabbarwal

Reputation: 3818

Wierd Issue with SplashScreen on Google Galaxy Nexus Phone

I have tried to do a lot of digging but I am not able to get to the problem of this problem of mine. The problem is with my app's splashscreen. The splashscreen runs without any issues on all devices/tablets except the Google Galaxy nexus. Instead of displaying the splashscreen I get to see a blank black screen and then the main screen of my app opens.

I checked the below logcat and there is one warning over there that looks like the culprit.

03-26 22:51:34.878: D/dalvikvm(26506): GC_FOR_ALLOC freed 30K, 1% free 8662K/8720K, paused 19ms, total 20ms
03-26 22:51:34.894: I/dalvikvm-heap(26506): Grow heap (frag case) to 12.390MB for 4096016-byte allocation
03-26 22:51:34.917: D/dalvikvm(26506): GC_FOR_ALLOC freed <1K, 1% free 12661K/12724K, paused 20ms, total 20ms
03-26 22:51:34.925: D/dalvikvm(26506): GC_CONCURRENT freed <1K, 1% free 12661K/12724K, paused 2ms+1ms, total 15ms
03-26 22:51:34.996: D/dalvikvm(26506): GC_FOR_ALLOC freed <1K, 1% free 12661K/12724K, paused 9ms, total 10ms
03-26 22:51:35.058: I/dalvikvm-heap(26506): Grow heap (frag case) to 28.013MB for 16384016-byte allocation
03-26 22:51:35.089: D/dalvikvm(26506): GC_FOR_ALLOC freed 0K, 1% free 28661K/28728K, paused 31ms, total 31ms
03-26 22:51:35.128: D/dalvikvm(26506): GC_CONCURRENT freed <1K, 1% free 28661K/28728K, paused 12ms+2ms, total 36ms
03-26 22:51:35.347: I/System.out(26506): true
03-26 22:51:35.503: D/libEGL(26506): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
03-26 22:51:35.535: D/libEGL(26506): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
03-26 22:51:35.542: D/libEGL(26506): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
03-26 22:51:35.917: D/OpenGLRenderer(26506): Enabling debug mode 0
03-26 22:51:36.027: W/OpenGLRenderer(26506): Bitmap too large to be uploaded into a texture (1600x2560, max=2048x2048)
03-26 22:51:36.871: V/CheatsDB.db(26506): db exists
03-26 22:51:37.207: D/dalvikvm(26506): GC_FOR_ALLOC freed 6206K, 18% free 28757K/35028K, paused 14ms, total 14ms

The line which says "Bitmap too large to be uploaded....". I have checked my drawables and there is no such image of that big size. The background image used by the splashscreen is 800 x 1280. This is the only png image that I use across all devices for now and the splash screen works fine on all other devices. Also the logcat says the the size of the image is looking like 1600 x 2560 which I believe is the resolution for my Nexus 10. I have not added any specific image of that size anywhere.

I am also posting my SplashScreen.java file code below :

public class SplashScreen extends Activity {

private final int SPLASH_DISPLAY_TIME = 1000;
private Handler splashHandler = new Handler();
private Runnable splashRunnable;
private final String firstLaunchCheck = "firstLaunchCheck";
SharedPreferences mPrefs;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.splash_screen);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);

    final Boolean isFirstLaunch = mPrefs.getBoolean(firstLaunchCheck, false);

    System.out.println(isFirstLaunch);

    splashRunnable = new Runnable() {
        @Override
        public void run() {

            if (!isFirstLaunch) {

                SharedPreferences.Editor editor = mPrefs.edit();
                editor.putBoolean(firstLaunchCheck, true);
                editor.commit();

                Intent mainIntent = new Intent(SplashScreen.this,
                        LookItUpTutorial.class);

                mainIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

                startActivity(mainIntent);
                SplashScreen.this.finish();


            }
            else {

                Intent mainIntent = new Intent(SplashScreen.this,
                        LandingPage.class);
                startActivity(mainIntent);

                SplashScreen.this.finish();
            }
        }
    };

    splashHandler.postDelayed(splashRunnable, SPLASH_DISPLAY_TIME);
}

// Remove any call back activities when back / home button is pressed on
// SplashScreen
@Override
public void onPause() {
    super.onPause();

    splashHandler.removeCallbacks(splashRunnable);
    SplashScreen.this.finish();
}
}

Also adding my layout :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/appbackground">

</LinearLayout>

Can anyone give me pointers on how I can go about tracking the cause of this problem ? I believe it has got something to do with the Image size warning but then I donot have any image that big in my source code. Any help will be greatly appreciated.

Thanks for stopping by and reading this big post.

Upvotes: 2

Views: 475

Answers (2)

toantran
toantran

Reputation: 1819

I have the same problem with you months ago. After several hours investigating. It seems the size of picture was to big ( the resolution of picture I used is 1400x1600). then I tried to re-scale it to 600x800 ( the quality is still acceptable) then it worked for me.

p/s I had this problem on Google Galaxy Nexus which is running JB 4.1.

Upvotes: 1

j__m
j__m

Reputation: 9645

Based on the layout you posted I have no idea why Android is scaling your image = ) But with a little work we can prevent it.

Remove android:drawable from your layout file and give the LinearLayout an Id. Then load the drawable yourself in code.

View mylinearlayout = findViewById(R.id.mylinearlayout);
Options options = new Options();
options.inScaled = false; // explicitly disable all scaling
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.appbackground, options);
mylinearlayout.setBackground(new BitmapDrawable(bmp));

Upvotes: 2

Related Questions