Login screen blinks with Toast

I created one login screen, but before the login screen appears, I need an image to appear on the screen. For this I use Toast. But the problem is that before the “Image Image Login” screen appears for a while, and after that the image starts blinking, the login screen appears again. I want to first flash the image before something appears on the screen. Here is my code:

    setContentView(R.layout.main);


    ImageView iv = new ImageView(this);
    iv.setImageDrawable(getResources().getDrawable(R.drawable.start));

    Toast t = new Toast(this);
    t.setView(iv);
    t.show();
    t.setDuration(5);

Thanks Deepak

+3
source share
1 answer

Handler LoginWindow , Handler , ,

Handler, , LifeCycle Activity, OnStart() .. ,

u..

private Handler handler;
private final static String DEBUG_TAG = "splashScreen";


public void onCreate(Bundle savedInstanceState) {
    Log.i(DEBUG_TAG, "onCreate executes ...");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscr);
    handler = new Handler(); 




}


public void onResume()
{ Log.i(DEBUG_TAG, "onResume executes ...");
handler.postDelayed(new Runnable()
{

    public void run()
    {
        Intent myIntent= new Intent(SplashScreen.this,TabCls.class);
        startActivity(myIntent);    
    }
}, 1000); 

super.onResume();
}


protected void onStart()
{
    super.onStart();
    Log.i(DEBUG_TAG, "onStart executes ...");
}




protected void onRestart()
{
    super.onRestart();
    Log.i(DEBUG_TAG, "onRestart executes ...");
}



protected void onPause()
{   
    super.onPause();
    Log.i(DEBUG_TAG, "onPause executes ...");

}


protected void onStop()
{
    super.onStop();
    Log.i(DEBUG_TAG, "onStop executes ...");
}    

protected void onDestroy()
{ 

    super.onDestroy();

    Log.i(DEBUG_TAG, "onDestroy executes ...");
}

}

+1

Source: https://habr.com/ru/post/1757986/


All Articles