My App launch slow. "black empty screen" (YT film)
<p>everybody :)</p>

<p>I am writing app, but I notice that launch of app take some time. When I click icon, there show empty screen although first what I am doing is show layut. Here is a film of alunching my app: <a href="https://youtu.be/rQjM9ysy6Yw" rel="nofollow">https://youtu.be/rQjM9ysy6Yw</a></p>

<p>There is no a lot of data to prepare. Of course launch is after register so there is key of sharedpreferences.</p>

<p>FIRST LOGIN ACTIVITY:</p>

<pre><code>public class Login extends AppCompatActivity {


private SharedPreferences loginPref;
private SharedPreferences.Editor loginPrefEditor;

private User userObj;


public void startMain(User user) {
    Intent passToMain = new Intent(Login.this, MainActivity.class);
    passToMain.putExtra("EXISTED_USER", user);
    startActivity(passToMain);
    finish();
}

@Override
protected void onCreate(Bundle savedInstanceState) {


   Log.w("LOGIN","START");




    setContentView(R.layout.activity_login);
    super.onCreate(savedInstanceState);




    loginPref = getSharedPreferences(MainActivity.LOGIN_SPREFERENCES, MODE_PRIVATE);
    loginPrefEditor = loginPref.edit();



    if (loginPref.contains("USER_PHONE")== true &amp;&amp; loginPref.contains("USER_PASSWORD")){

        userObj = new User();
        userObj.setPhoneNumber(loginPref.getInt("USER_PHONE", 0));
        userObj.setPassword(loginPref.getString("USER_PASSWORD", ""));
        userObj.setName(loginPref.getString("USER_NAME", ""));
        userObj.setCity(loginPref.getString("USER_CITY", ""));
        userObj.setDateBirthday(loginPref.getLong("USER_BIRTHDAY", 0L));

        startMain(userObj);

        finish();
        Log.w("LOGIN", "finished");




    }else{
        LoginStartFragment loginFragment = new LoginStartFragment();

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.layoutLoginFragment, loginFragment ).addToBackStack(null).commit();
    }
</code></pre>

<p>SECOND ACTIVITY:</p>

<pre><code>public class MainActivity extends AppCompatActivity implements       LoginAsyncTask.CommunicationActivServ {
   public static final String LOGIN_SPREFERENCES =      "com.mmc.mateusz.gymudies.MY_LOGIN_PREF";
public User Me;
public ListFragmentUsers listFragmentUsers=null;
public MyProfil myProfil=null;


public  FloatingActionButton fabBeBuddy;
public ViewPager viewPager;
public TabsAdapter tabsAdapter;

public LoginAsyncTask loginAsyncTask;

public TabLayout tabLayout;

private ImageView avatar;

public int lastPosition=1;

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

    tabLayout = (TabLayout)findViewById(R.id.tabLayout);
    avatar = (ImageView)findViewById(R.id.my_avatar);
    fabBeBuddy = (FloatingActionButton)findViewById(R.id.fabBeBuddy);

    Me = new User();
    Intent getU = getIntent();
    if (getU.hasExtra("EXISTED_USER") == true) {
        Me = (User) getU.getSerializableExtra("EXISTED_USER");
    }


    if (listFragmentUsers!=null){
        if (listFragmentUsers.isVisible()!=false){
            lastPosition =  viewPager.getCurrentItem();
        }
    }

    listFragmentUsers = new ListFragmentUsers();
    listFragmentUsers.setMe(Me);
    //listFragmentUsers.pobierzDane();

    myProfil=new MyProfil(Me);

    tabsAdapter = new TabsAdapter(getSupportFragmentManager(),listFragmentUsers, myProfil);
    viewPager = (ViewPager)findViewById(R.id.pager);

    viewPager.setAdapter(tabsAdapter);
    viewPager.setCurrentItem(lastPosition);
    tabLayout.addTab(tabLayout.newTab().setText("GYM BUDDIES"));
    tabLayout.addTab(tabLayout.newTab().setText("TWÓJ PROFIL"));

    tabLayout.setupWithViewPager(viewPager);
    Log.w("MAINACTIVITY", "tabsy widac");


    fabBeBuddy.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loginAsyncTask = new LoginAsyncTask(MainActivity.this, Me);
            loginAsyncTask.execute(LoginAsyncTask.REQUEST_SET_ME_BUDDY);
        }
    });

    loginAsyncTask = new LoginAsyncTask(MainActivity.this, Me);
    loginAsyncTask.execute(LoginAsyncTask.REQUEST_GET_STATUS_ME_BUDDY);
    Log.w("MAINACTIVITY", "main pobiera teraz dane");


}

private void checkIfWiFiIsEnabled() {
    WifiManager wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
    if (!wifi.isWifiEnabled()){
        FragmentYesNo yesnowifi = new FragmentYesNo(this);
        yesnowifi.show(getFragmentManager(),"ENABLEWIFI");
    }
}

private void showOfflineFragment() {
    LinearLayout offlineLay = (LinearLayout)findViewById(R.id.offline_frag);
    offlineLay.setVisibility(View.VISIBLE);
}


public void uruchomProfil(){
    Intent passObj = new Intent(MainActivity.this, Profil.class);
    passObj.putExtra("EXISTED_USER", Me);

    startActivity(passObj);
    finish();
}


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

}
@Override
protected void onPostResume() {
    super.onPostResume();

}

@Override
protected void onResume() {
    super.onResume();

}


@Override
public void onFinishAsyncTask() {
    if (loginAsyncTask.getRequest()==LoginAsyncTask.REQUEST_SET_ME_BUDDY ||
            loginAsyncTask.getRequest()==LoginAsyncTask.REQUEST_GET_STATUS_ME_BUDDY){

        if (loginAsyncTask.getBuddyStatus() == true){
            fabBeBuddy.setImageResource(R.drawable.ic_cancel_24dp);
        }else{
            fabBeBuddy.setImageResource(R.drawable.ic_add_circle_24dp);
        }

    }
}


public void showToast(String text){
    Context context = getApplicationContext();
    //CharSequence text = "Hello toast!";
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, text, duration);
    toast.show();
}

}
</code></pre>

<p>Can anyone help me to speed up launch of my app?</p>