content: package com.photoselector.util;
  
  import com.photoselector.ui.PhotoSelectorActivity;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.Bundle;
  import android.provider.MediaStore.Images.ImageColumns;
  import android.util.DisplayMetrics;
  
  /**
   * ͨù
   * 
   * @author chenww
   * 
   */
  public class CommonUtils {
  
  	/**
  	 * activity
  	 */
  	public static void launchActivity(Context context, Class<?> activity) {
  		Intent intent = new Intent(context, activity);
  		intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  		context.startActivity(intent);
  	}
  
  	/**
  	 * activity()
  	 */
  	public static void launchActivity(Context context, Class<?> activity, Bundle bundle) {
  		Intent intent = new Intent(context, activity);
  		intent.putExtras(bundle);
  		intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  		context.startActivity(intent);
  	}
  
  	/**
  	 * activity()
  	 */
  	public static void launchActivity(Context context, Class<?> activity, String key, int value) {
  		Bundle bundle = new Bundle();
  		bundle.putInt(key, value);
  		launchActivity(context, activity, bundle);
  	}
  
  	public static void launchActivity(Context context, Class<?> activity, String key, String value) {
  		Bundle bundle = new Bundle();
  		bundle.putString(key, value);
  		launchActivity(context, activity, bundle);
  	}
  
  	public static void launchActivityForResult(Activity context, Class<?> activity, int requestCode) {
  		Intent intent = new Intent(context, activity);
  		intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  		context.startActivityForResult(intent, requestCode);
  	}
  	
  	public static void launchActivityForResult(Activity context, Class<?> activity, int requestCode, int maxImage) {
  		Intent intent = new Intent(context, activity);
  		intent.putExtra(PhotoSelectorActivity.KEY_MAX, maxImage);
  		intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  		context.startActivityForResult(intent, requestCode);
  	}
  
  	public static void launchActivityForResult(Activity activity, Intent intent, int requestCode) {
  		activity.startActivityForResult(intent, requestCode);
  	}
  
  	/** һ */
  	public static void launchService(Context context, Class<?> service) {
  		Intent intent = new Intent(context, service);
  		context.startService(intent);
  	}
  
  	public static void stopService(Context context, Class<?> service) {
  		Intent intent = new Intent(context, service);
  		context.stopService(intent);
  	}
  
  	/**
  	 * жַǷΪ
  	 * @param text
  	 * @return true null false !null
  	 */
  	public static boolean isNull(CharSequence text) {
  		if (text == null || "".equals(text.toString().trim()) || "null".equals(text))
  			return true;
  		return false;
  	}
  
  	/** ȡĻ */
  	public static int getWidthPixels(Activity activity) {
  		DisplayMetrics dm = new DisplayMetrics();
  		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
  		return dm.widthPixels;
  	}
  
  	/** ȡĻ߶ */
  	public static int getHeightPixels(Activity activity) {
  		DisplayMetrics dm = new DisplayMetrics();
  		activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
  		return dm.heightPixels;
  	}
  
  	/** ͨUriȡͼƬ· */
  	public static String query(Context context, Uri uri) {
  		Cursor cursor = context.getContentResolver().query(uri, new String[] { ImageColumns.DATA }, null, null, null);
  		cursor.moveToNext();
  		return cursor.getString(cursor.getColumnIndex(ImageColumns.DATA));
  	}
  
  }
  