Monday, May 1, 2017

Making of 8 or Bust ---- a Mathematical Puzzle

Splash Screen
https://play.google.com/store/apps/details?id=com.siddbetter.numbercrunchpaid


Android games in the native platform are built using Java using Android SDK. I used IDE Android Studio for developing 8 Or Bust. Android Studio on the creation of a project create a default app folder and build tool used is Gradle. 
                            
Now, the first screen of almost all apps is a splash screen which is shown for few seconds and then the main screen appears.
    
 public class MainActivity extends BaseActivity {
         private static final int splash_time = 30;
         @Override
            protected void onCreate(Bundle savedInstanceState) {
                setTheme(R.style.AppTheme);
                getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |               
                    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_main);
                           }
                       @Override
           public void onWindowFocusChanged(boolean hasFocus) {

            if (!hasFocus || animationStarted) {
               return;
            }

             new SplashTask().execute();

             super.onWindowFocusChanged(hasFocus);
         }

         @Override
          public void onNewIntent(Intent intent) {
             super.onNewIntent(intent);
             Localytics.onNewIntent(this,intent);
          }

         @Override
         public void onStop() {
             super.onStop();

         }

        private class SplashTask extends AsyncTask {
            @Override
            protected Void doInBackground(Void... params) {
                try {

                   Thread.sleep(splash_time); /// show splash screen for 
                } catch (InterruptedException e) {
                   e.printStackTrace();
                }
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                super.onPostExecute(result);
                startNextActivity(); // then move over to next screen 
            }

         }



         private void startNextActivity() {
             BaseUtility.startNextActivity(this, LoginActivity.class);
             finish();

         }
}


BaseUtiltiy---
     public static void startNextActivity(Activity activity,Class className){
         Intent intent = new Intent(activity,className);
         activity.startActivity(intent);
         activity.overridePendingTransition(android.R.anim.slide_in_left,                   android.R.anim.slide_out_right);
      }


This splash screen after showing for 30ms loads the next Screen -- Login.

No comments:

Post a Comment