开发者

Splash screen only shows after clean install

开发者 https://www.devze.com 2023-03-05 08:48 出处:网络
I have made a splash screen with an Activity. I followed following example http://www.anddev.org/viewtopic.php?t=815 and it works perfectly when installed. But that\'s where my problem starts. It only

I have made a splash screen with an Activity. I followed following example http://www.anddev.org/viewtopic.php?t=815 and it works perfectly when installed. But that's where my problem starts. It only shows after an install. So When I kill my app, the Activity isn't loaded anymore, it directly loads my second Activity. I think it's a little weird, because I set the intent-filter in my manifestfile on the splash screen.

Anyone knows how to solve this problem?

This is my manifestfile:

<application android:icon="@drawable/icon" android:label="@string/app_name" 
android:theme="@style/MyLightTheme.NoShadow" android:debuggable="true"  android:name="android.app.Application" > 
<uses-library android:name="com.google.android.maps" />

    <activity android:name=".MainActivity" android:label="@string/app_name"></activity>
    <activity android:name="FindJob" android:label="@string/FindJobTitel"></activity>
    <activity android:name="JobDetails" android:label="@string/MaatTitel" ></activity>
    .
    .
    .
    <activity android:name="Splash" android:configChanges="orientation" android:label="@string/Splash">    
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter></activity>
</application>

Splashscreencode:

private final int SPLASH_DISPLAY_LENGHT = 5000;
//private Drawable drawable;
private ProgressBar mProgress;
private int mProgressStatus = 0;


/** Called when the activity is first created. */ 
@Override
public void onCreate(Bundle icicle) {
     super.onCreate(icicle);          
     setContentView(R.layout.splash);         
     mProgress = (ProgressBar)开发者_JAVA技巧 findViewById(R.id.progressBar1);         
     }


public void onStart(){
    super.onStart();
    //Log.i("START", "In on start");
    Thread splashThread = new Thread() {
        @Override
        public void run() {
           try {
              int waited = 0;
              while (mProgressStatus < 100) {
                 sleep(80);
                 //waited += 200;
                 mProgressStatus += 4;
                 mProgress.setProgress(mProgressStatus);
              }
           } catch (InterruptedException e) {
              // do nothing
           } finally {
              finish();
             Intent i = new Intent(Splash.this, MainActivity.class);
              startActivity(i);
           }
        }
     };
     splashThread.start();   
}

UPDATE: placing android:noHistory="true" in the mainActivity in ManifestFile solves the problem. HOWEVER. Each time I leave the app, it restarts all of it (splash screen, mainactivity and not last activity loaded). But it's better then before.

0

精彩评论

暂无评论...
验证码 换一张
取 消