Example usage for android.content Intent setClass

List of usage examples for android.content Intent setClass

Introduction

In this page you can find the example usage for android.content Intent setClass.

Prototype

public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) 

Source Link

Document

Convenience for calling #setComponent(ComponentName) with the name returned by a Class object.

Usage

From source file:Main.java

public static void turnToActivityWithData(Context context, Class activityClass, Serializable bean) {
    Intent intent = new Intent();
    intent.putExtra(data_flag, bean);// ww w.j  a  va 2  s. c  o m
    intent.setClass(context, activityClass);
    context.startActivity(intent);
}

From source file:Main.java

public static void startActivityByClassName(Context mContext, String className) {
    try {/*ww w .ja  v a 2  s .c o m*/
        Intent intent = new Intent();
        intent.setClass(mContext, Class.forName(className));
        mContext.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void jumpToResActivity(Context context, Class<?> cls, Bundle bundle, int requestCode) {
    Intent jumpIntent = new Intent();
    if (bundle != null)
        jumpIntent.putExtras(bundle);/*w ww .  jav a2 s  . co  m*/
    jumpIntent.setClass(context, cls);
    ((Activity) context).startActivityForResult(jumpIntent, requestCode);
}

From source file:Main.java

public static void jumpToActivity(Context context, Class<?> cls, Bundle bundle) {
    Intent jumpIntent = new Intent();
    if (bundle != null)
        jumpIntent.putExtras(bundle);/*from w w w .  j ava 2 s  .co  m*/
    jumpIntent.setClass(context, cls);
    context.startActivity(jumpIntent);
}

From source file:com.app.common.util.IntentUtils.java

public static void start_activity(Activity activity, Class<?> cls, BasicNameValuePair... name) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);
    for (int i = 0; i < name.length; i++) {
        intent.putExtra(name[i].getName(), name[i].getValue());
    }/*from ww w.  j av  a2  s . c  om*/
    activity.startActivity(intent);
}

From source file:com.app.common.util.IntentUtils.java

public static void startActivity(Activity activity, Class<?> cls, Bundle bundle) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);
    if (null != bundle) {
        intent.putExtras(bundle);/*ww w .  j a v  a 2 s. c  o  m*/
    }

    activity.startActivity(intent);
}

From source file:com.app.common.util.IntentUtils.java

public static void startActivityForResult(Activity activity, Class<?> cls, Bundle bundle, int requestCode) {
    Intent intent = new Intent();
    intent.setClass(activity, cls);
    if (null != bundle) {
        intent.putExtras(bundle);//from  w ww .jav  a 2 s.co  m
    }

    activity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void openActivity(Activity activity, Class<?> pClass, String pAction, Bundle pBundle,
        int requestCode) {
    if (null == activity)
        return;//  w  w  w  .j a  v  a 2 s  .  co  m

    Intent intent = new Intent(pAction);
    intent.setClass(activity, pClass);
    if (pBundle != null) {
        intent.putExtras(pBundle);
    }

    if (requestCode < 0) {
        activity.startActivity(intent);
    } else {
        activity.startActivityForResult(intent, requestCode);
    }
}

From source file:com.liferay.alerts.receiver.WearableVoteReceiver.java

protected static PendingIntent getPendingIntent(Context context, long alertId, PollsQuestion question) {

    Intent intent = new Intent(ACTION_VOTE);
    intent.setClass(context, WearableVoteReceiver.class);
    intent.putExtra(EXTRA_QUESTION, question);
    intent.putExtra(EXTRA_ALERT_ID, alertId);

    return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:com.meet.ychmusic.activity.PhotoDetailsActivity.java

public static Intent createIntent(Context context, String[] array, int index) {
    Intent intent = new Intent();
    intent.setClass(context, PhotoDetailsActivity.class);
    intent.putExtra("album", array);
    intent.putExtra("index", index);
    return intent;
}