본문 바로가기
Android

postDelayed

by 캡틴노랑이 2021. 8. 4.
반응형

 

public class MainActivity extends Activity {
    final Handler handler = new Handler();

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

        auth();

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                gotoLogin();
            }
        }, 1000 * 2);
    }

    protected void auth()
    {

    }

    protected void gotoLogin()
    {
        Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
        try {
            //다른 화면 전환
            startActivity(intent);
        }catch (Exception e)
        {
            e.printStackTrace();
        }
    }

}

반응형

댓글