Example usage for android.app Activity startActivity

List of usage examples for android.app Activity startActivity

Introduction

In this page you can find the example usage for android.app Activity startActivity.

Prototype

@Override
public void startActivity(Intent intent) 

Source Link

Document

Same as #startActivity(Intent,Bundle) with no options specified.

Usage

From source file:Main.java

/**
 * Launch an intent in the CATEGORY_DEFAULT.
 * @param activity The activity to launch from
 * @param intent The intent to launch// ww  w  .j av a2  s  .  com
 */
public static void launchDefaultIntent(final Activity activity, final Intent intent) {
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    activity.startActivity(intent);
}

From source file:Main.java

public static void startActivityAndDestroy(Activity activity, Class<? extends Activity> clazz) {
    Intent intent = new Intent(activity, clazz);
    activity.startActivity(intent);
    activity.finish();/*from  w w  w .ja  v  a  2 s. com*/
}

From source file:Main.java

public static void createActivity(Activity activity, Class<?> activityClass) {
    Intent intent = new Intent(activity, activityClass);
    activity.startActivity(intent);
}

From source file:Main.java

public static void openURL(Activity activity, String url) {
    Intent webIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    activity.startActivity(webIntent);
}

From source file:Main.java

/**
 * @param fromActivity the activity from where we want to switch
 * @param toActivity   the class name of the  activity where we are switching to
 *///  w  w  w  .  ja  v  a  2  s. co  m

public static void switchActivity(Activity fromActivity, Class toActivity) {
    Intent intent = new Intent(fromActivity, toActivity);
    fromActivity.startActivity(intent);
}

From source file:Main.java

public static void openBrowser(Activity activity, String url) {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    activity.startActivity(browserIntent);
}

From source file:Main.java

public static void startActivity(Activity activity, Class clazz, boolean isFinish) {
    Intent intent = new Intent(activity, clazz);
    activity.startActivity(intent);
    if (isFinish) {
        activity.finish();//from   www  .j a va  2s .  c o  m
    }
}

From source file:Main.java

public static void startActivity(Activity activity, Class claz, boolean finish, int delay) {
    Intent intent = new Intent(activity, claz);
    activity.startActivity(intent);
    if (finish) {
        activity.finish();/*from w  w w . ja  v  a2s  .  c o m*/
    }
}

From source file:Main.java

public static void startActivity(Activity activity, Class<?> cls) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);//from  w w  w .j  a  va  2s .c o m
    activity.startActivity(intent);

}

From source file:Main.java

/**
 * //from   w  w  w.ja  v  a2s.com
 * @param activity
 * @param url
 */
public static void openBrowserWithUrl(Activity activity, String url) {
    Intent openBrowserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    activity.startActivity(openBrowserIntent);
}