jump Post To Activity - Android Activity

Android examples for Activity:Activity Jump

Description

jump Post To Activity

Demo Code


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

import android.content.Context;
import android.content.Intent;

import android.os.AsyncTask;

public class Main {
    public static void jumpPostToActivity(final Context context,
            final Intent datatIntent, final int second) {
        (new AsyncTask<String, Integer, Boolean>() {
            protected Boolean doInBackground(String... params) {
                try {
                    Thread.sleep((long) (second * 1000));
                } catch (Exception var3) {

                }/*from w ww .  j a v a  2 s .  co m*/
                return null;
            }

            protected void onPostExecute(Boolean result) {
                super.onPostExecute(result);
                context.startActivity(datatIntent);
            }
        }).execute(new String[] { "" });
    }

    public static void jumpPostToActivity(final Context context,
            final Class<? extends Activity> targetClass, final int second) {
        (new AsyncTask<String, Integer, Boolean>() {
            protected Boolean doInBackground(String... params) {
                try {
                    Thread.sleep((long) (second * 1000));
                } catch (Exception var3) {
                    ;
                }
                return null;
            }

            protected void onPostExecute(Boolean result) {
                super.onPostExecute(result);
                Intent datatIntent = new Intent(context, targetClass);
                context.startActivity(datatIntent);
            }
        }).execute(new String[] { "" });
    }

    public static void jumpPostToActivity(final Context context,
            final Class<? extends Activity> targetClass, final int second,
            final String... datas) {
        (new AsyncTask<String, Integer, Boolean>() {
            protected Boolean doInBackground(String... params) {
                try {
                    Thread.sleep((long) (second * 1000));
                } catch (Exception var3) {
                    ;
                }
                return null;
            }

            protected void onPostExecute(Boolean result) {
                super.onPostExecute(result);
                Intent datatIntent = new Intent(context, targetClass);
                if (datas != null) {
                    for (int i = 0; i < datas.length; ++i) {
                        datatIntent.putExtra("data" + i, datas[i]);
                    }
                }

                context.startActivity(datatIntent);
            }
        }).execute(new String[] { "" });
    }
}

Related Tutorials