2017-10-16 15 views
0

最初のランチ後にスプラッシュ画面を表示するwebviewアプリケーションを作成しようとしています。最初にアプリを開くとスプラッシュ画面が表示され、5秒後にメインアクティビティVaultActivityがロードされますが、スプラッシュ画面 'SplashScreen'が起動されたかどうかを確認するコード行が追加された後、アプリはロードを停止しますVaultActivitySPLASH_TIME_OUT私は設定してもスプラッシュ画面を使用して私はいつでも私はアプリをランチ表示されます。Webviewスプラッシュ画面は一度は表示されません

最初

public class SplashScreen extends Activity { 

    private static int SPLASH_TIME_OUT = 5000; // Splash screen timer 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash); 

      new Handler().postDelayed(new Runnable() { 
       @Override 
       public void run() { 
        // Start main activity 
        Intent intent = new Intent(SplashScreen.this, VaultActivity.class); 
        startActivity(intent); 
        finish(); 
       } 
      }, SPLASH_TIME_OUT); 

    } 
} 

現在

public class SplashScreen extends Activity { 

    private static int SPLASH_TIME_OUT = 5000; // Splash screen timer 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_splash); 

     SharedPreferences pref = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE); 
     if(pref.getBoolean("activity_executed", false)){ 
      new Handler().postDelayed(new Runnable() { 
       @Override 
       public void run() { 
        // Start main activity 
        Intent intent = new Intent(SplashScreen.this, VaultActivity.class); 
        startActivity(intent); 
        finish(); 
       } 
      }, SPLASH_TIME_OUT); 
     } else { 
      SharedPreferences.Editor ed = pref.edit(); 
      ed.putBoolean("activity_executed", true); 
      ed.commit(); 
     } 
    } 
} 

私のマニフェストあなたは星を呼び出す必要があり

<activity 
     android:name=".SplashScreen" 
     android:launchMode="singleTask" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <activity android:name=".VaultActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="android.intent.action.VIEW" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <category android:name="android.intent.category.BROWSABLE" /> 
      <data android:scheme="http" 
       android:host="example.com" 
       android:pathPrefix="/androidmobile" /> 
     </intent-filter> 
    </activity> 

答えて

0

:) elseセクションにstartActivityを追加するだけです。

public class SplashScreen extends Activity { 



      private static int SPLASH_TIME_OUT = 5000; // Splash screen timer 

      @Override 
      protected void onCreate(Bundle savedInstanceState) { 
       super.onCreate(savedInstanceState); 
       setContentView(R.layout.activity_splash); 

       SharedPreferences pref = getSharedPreferences("ActivityPREF", Context.MODE_PRIVATE); 
final SharedPreferences.Editor ed = pref.edit() 
       if(pref.getBoolean("activity_executed", false)){ 
        //ed.putBoolean("activity_executed", true); 
        //ed.commit(); 

    Intent intent = new Intent(SplashScreen.this, VaultActivity.class); 
          startActivity(intent); 
          finish(); 
       } else { 
        new Handler().postDelayed(new Runnable() { 
         @Override 
         public void run() { 
          // Start main activity 
          Intent intent = new Intent(SplashScreen.this, VaultActivity.class); 
          startActivity(intent); 

        ed.putBoolean("activity_executed", true); 
        ed.commit(); 

          finish(); 
         } 
        }, SPLASH_TIME_OUT); 

       } 
      } 
     } 
+0

はまだ、私はちょうどそれをテストしていない、それはそれがない次のランチに、その後の昼食最初の昼食のスプラッシュ画面をしません – Peter

0

他人の活動。

関連する問題