码迷,mamicode.com
首页 > 移动开发 > 详细

Android FragmentActivity Intent 跳转封装

时间:2014-12-18 12:06:22      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:des   android   blog   ar   io   java   on   2014   art   

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 跳转封装

标签:des   android   blog   ar   io   java   on   2014   art   

原文地址:http://blog.csdn.net/xufeifandj/article/details/42002189

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!