Start Activity by Intent - Android android.app

Android examples for android.app:Activity Start

Description

Start Activity by Intent

Demo Code

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

public class Main {

  public static void intentActivity(Context starter, String action, String category) {

    Intent intent = new Intent();

    if (null != action && action != "")
      intent.setAction(action);/*  w ww.  jav  a2  s.c  o  m*/

    if (null != category && category != "")
      intent.addCategory(category);

    if (null != starter)
      starter.startActivity(intent);
  }

  public static void intentActivity(Context starter, Intent intent) {

    starter.startActivity(intent);
  }

  public static void intentActivity(Context starter, Class<?> target) {

    if (null == starter || null == target)
      return;

    Intent intent = new Intent();
    intent.setClass(starter, target);
    starter.startActivity(intent);
  }

}

Related Tutorials