4

私の Android アプリでは、スプラッシュ スクリーンを使用しました。しかし、スプラッシュが消えると、次の画面が黒くなり、メイン アクティビティに切り替わります。しかし、私は黒い画面が欲しくありません。ここで何が起こっているのか、どうすればその黒い画面を防ぐことができるのか、誰か説明してもらえますか? これは私の SplashActivity クラスです。

package my.easymedi.controller;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class SplashActivity extends Activity {
private static int SPLASH_TIME_OUT = 3000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            Intent i = new Intent(getApplicationContext(),
                    MainActivity.class);
            startActivity(i);
        }
    }, SPLASH_TIME_OUT);
}

}

これは私のマニフェスト ファイルです。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.easymedi.controller"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<!-- Permissions -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<application
    android:allowBackup="true"
    android:icon="@drawable/easy_medi"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="my.easymedi.controller.SplashActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".MainActivity" android:label="@string/app_name" android:screenOrientation="portrait"></activity>
</application>

私の丸太猫は次のようなものです:

10-22 11:19:59.699: E/Trace(1161): error opening trace file: No such file or directory (2)
10-22 11:19:59.699: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:19:59.699: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:19:59.699: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:00.488: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:00.488: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:00.968: D/dalvikvm(1161): GC_FOR_ALLOC freed 123K, 9% free 2584K/2824K, paused 44ms, total 47ms
10-22 11:20:01.078: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.078: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.089: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.108: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.178: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.178: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.188: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.279: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.298: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.298: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.298: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.298: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.298: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.328: D/gralloc_goldfish(1161): Emulator without GPU emulation detected.
10-22 11:20:01.389: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:01.438: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:04.138: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:04.198: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:04.198: W/Trace(1161): Unexpected value from nativeGetEnabledTags: 0
10-22 11:20:04.758: D/dalvikvm(1161): GC_CONCURRENT freed 25K, 6% free 2954K/3116K, paused 73ms+14ms, total 177ms
10-22 11:20:04.758: D/dalvikvm(1161): WAIT_FOR_CONCURRENT_GC blocked 65ms
10-22 11:20:04.878: I/System.out(1161): ===false===
10-22 11:20:05.078: I/System.out(1161): ***copy db***
4

3 に答える 3

0

Threadおそらく、代わりに単純なものを使用したいかもしれませんHandler

private static final long splash_time = 1000;

Thread splashTread = new Thread() {
        @Override
        public void run() {
            try {
                Thread.sleep(splash_time);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                Intent main = new Intent(getApplicationContext(),
                        MainActivity.class);
                startActivity(main);
                finish();
            }
        }
    };

次に、で、次の方法onCreateでスレッドを開始できます

    splashTread.start();
于 2013-10-22T11:21:03.297 に答える