首页 > 代码库 > Android FragmentActivity Intent 跳转封装

Android FragmentActivity Intent 跳转封装

package com.innjoo.store.utils;

import com.innjoo.store.R;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;

public class IntentUtils {
	private static Intent intent;
	private static final Object lock = new Object();
	public static final int ENTER = 0, OUT = 1, NOTRANSITION = -1;

	/**
	 * 
	 * @Title: startActivityEnter
	 * @Description: TODO 跳转进入
	 * @return void
	 * @throws
	 * @author 重播
	 * @email 459821731@qq.com
	 * @date 2014-12-18 上午10:05:16
	 */
	public static <T> void startActivity(int inOrOut,
			FragmentActivity activity, Class<T> class1, String key,
			Object object) {
		// TODO Auto-generated method stub
		synchronized (lock) {
			try {

				intent = new Intent(activity, class1);
				if (object != null && object instanceof String) {
					intent.putExtra(key, (String) object);
				} else if (object != null && object instanceof Integer) {
					intent.putExtra(key, (Integer) object);
				}
				activity.startActivity(intent);
				switch (inOrOut) {
				case ENTER:
					activity.overridePendingTransition(
							R.anim.activity_right_in, R.anim.activity_left_out);
					break;
				case OUT:
					activity.overridePendingTransition(R.anim.activity_left_in,
							R.anim.activity_right_out);
					break;
				default:
					break;
				}

			} catch (ActivityNotFoundException e) {

			}
		}

	}

}

Android FragmentActivity Intent 跳转封装