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

public static <T extends Activity> void startActivity(Activity parent, Class<T> clazz, boolean killParent) {
    Intent intent = new Intent(parent, clazz);
    if (killParent) {
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    }/*w w w .j av  a2  s  . c  o  m*/
    parent.startActivity(intent);

    if (killParent) {
        parent.finish();
    }
}

From source file:Main.java

public static void startNewActivity(Activity origin, Class<? extends Activity> newActivity, Bundle bundle) {
    Intent intent = new Intent(origin.getBaseContext(), newActivity);
    if (bundle != null)
        intent.putExtras(bundle);//from ww w. j  a  v  a2  s  .  c  o  m
    origin.startActivity(intent);
}

From source file:com.agna.setmaster.ui.screen.main.MainActivity.java

public static void start(Activity activity) {
    Intent i = new Intent(activity, MainActivity.class);
    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.finish();/*from ww w .  java2s .  c o m*/
    activity.startActivity(i);
}

From source file:Main.java

public static boolean sendEmailToDeveleper(Activity act) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse("https://mail.qq.com");
    intent.setData(content_url);/*from w ww  .jav a  2s.  com*/
    act.startActivity(intent);
    return true;
}

From source file:Main.java

public static void openActivity(Activity activity, Intent intent) {
    if (null == activity || null == intent)
        return;// w  ww .  j  a  va2 s  . c om

    activity.startActivity(intent);
}

From source file:Main.java

public static void dialNumber(Activity context, String phoneNumber) {
    if (context == null) {
        return;//from   www.j  a  v a  2s  .  c o m
    }
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setData(Uri.parse("tel:" + phoneNumber));
    context.startActivity(intent);
}

From source file:Main.java

/**
 * @param activity//from ww w.  j a v  a 2 s.c o  m
 * @param phone
 */
public static void phone(Activity activity, String phone) {

    phone = "tel:" + phone.trim();

    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(phone));

    activity.startActivity(intent);

}

From source file:Main.java

public static void goTo(Activity aty, Class clazz, Bundle bundle, boolean isFinish) {
    Intent intent = new Intent(aty, clazz);
    if (bundle != null) {
        intent.putExtras(bundle);/*from w ww.  j a  v a2  s.  co  m*/
    }
    aty.startActivity(intent);
    if (isFinish) {
        aty.finish();
    }
}

From source file:Main.java

/**
 * call when you need to transit form one activity to another
 * @param shouldFinishContext: true if you want to finish context of the current activity, false otherwise
 *//*from  ww w  .ja  va2s  .co  m*/
public static void changeActivity(Activity source, Class<?> destination, Boolean shouldFinishContext) {
    if (shouldFinishContext) {
        source.finish();
    }
    Intent intent = new Intent(source, destination);
    source.startActivity(intent);
}

From source file:Main.java

public static void startActivityNoHistory(Activity activity, Class classActivity) {
    Intent intent = new Intent();
    intent.setClass(activity, classActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.startActivity(intent);
}