Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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) {

                }
                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[] { "" });
    }
}