我試圖做很多挖掘,但我無法解決我的這個問題。問題出在我的應用程序的啓動畫面上。除了Google Galaxy聯繫之外,所有設備/平板電腦上的splashscreen運行都沒有任何問題。而不是顯示splashscreen我看到一個空白的黑色屏幕,然後打開我的應用程序的主屏幕。谷歌Galaxy Nexus手機上的SplashScreen的奇怪問題
我檢查了下面的logcat,那裏有一個警告,看起來像罪魁禍首。
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
說「位圖太大無法上傳....」的行。我已經檢查了我的drawable,並沒有那麼大的圖像。啓動畫面使用的背景圖像是800 x 1280.這是目前我在所有設備上使用的唯一png圖像,啓動畫面在所有其他設備上都能正常工作。此外,logcat說圖像的大小看起來像1600 x 2560,我相信它是我的Nexus 10的分辨率。我沒有在任何地方添加任何具體尺寸的圖像。
我也張貼下面我SplashScreen.java文件代碼:
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();
}
}
也增加了我的佈局:
<?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>
誰能給我我怎麼能去跟蹤的原因指針這個問題 ?我相信它與圖像大小警告有關,但是我沒有在我的源代碼中有任何大的圖像。任何幫助將不勝感激。
感謝您停下來閱讀這篇大文章。
我建議你應該減少你的啓動畫面圖像到400x640,看看症狀是否改變。 – 2013-03-27 06:38:33