How to display a one time welcome screen?

前端 未结 3 1358
太阳男子
太阳男子 2020-12-01 03:19

In my android app, I need to design a Welcome Screen which will be shown to the user only once after the app is installed and opened. The app in question is a database drive

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 03:42

    I created a SplashScreen with this:

    package com.olidroide;
    
    
    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.Message;
    
    
    public class SplashScreen extends Activity{
    /** Called when the activity is first created. */
         public ProgressDialog myDialog; 
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
            setContentView(R.layout.splashscreen);
    
            new Handler().postDelayed(new Runnable() {
    
                public void run() { 
                    myDialog = ProgressDialog.show(SplashScreen.this,"", "Loading", true);
    
                    Intent intent=new Intent(SplashScreen.this,OtherActivity.class);
                    SplashScreen.this.startActivity(intent);
                    myDialog.dismiss();
                    SplashScreen.this.finish();     
                }
    
            }, 3000);// 3 Seconds
        }
    };
    

提交回复
热议问题