start New Activity - Android Activity

Android examples for Activity:Activity Start

Description

start New Activity

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Intent;

import android.os.Handler;

public class Main {

    public static void startNewActivity(final Activity from,
            final Class<?> to, long delayMillis, final boolean finishSelf) {

        Handler handler = new Handler();
        Runnable r = new Runnable() {
            @Override//from  ww  w.  j av a  2s  .c  om
            public void run() {
                Intent intent = new Intent(from, to);
                from.startActivity(intent);
                if (finishSelf == true)
                    from.finish();
            }
        };
        handler.postDelayed(r, delayMillis);
    }
}

Related Tutorials