Example usage for android.content Intent Intent

List of usage examples for android.content Intent Intent

Introduction

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

Prototype

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

Source Link

Document

Create an intent for a specific component.

Usage

From source file:Main.java

public static void startService(Context context, Class<? extends Service> type) {
    context.startService(new Intent(context, type));
}

From source file:Main.java

public static void enterActivityWithBundle(Activity activity, Class clz, Bundle bundle) {
    Intent intent = new Intent(activity, clz);
    intent.putExtras(bundle);/* ww  w  .  j  av  a 2 s  . c  o  m*/
    activity.startActivity(intent);
}

From source file:Main.java

public static <T extends Activity> void display(Context context, Class<T> clazz) {
    context.startActivity(new Intent(context, clazz));
}

From source file:Main.java

public static final void invokeWithArgs(Activity activity, Class<?> clazz, Bundle bundle) {
    Intent intent = new Intent(activity, clazz);
    intent.putExtra("bundle", bundle);
    activity.startActivity(intent);//  w  ww  .  j a va2s .  c om
}

From source file:Main.java

private static PendingIntent makeMoodIntent(Context context, Class class1) {
    Intent intent = new Intent(context, class1);
    intent.addFlags(0x400000);/* www . j a v a2 s.  com*/
    intent.addFlags(0x4000000);
    return PendingIntent.getActivity(context, 1, intent, 0x10000000);
}

From source file:Main.java

public static void openUrl(Context context, String url) {
    Uri uri = Uri.parse(url);/*from  ww w  . j  a  v a  2  s . c  om*/
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    context.startActivity(intent);
}

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);
    }/*from w ww.  jav  a2s  . c  o  m*/
    parent.startActivity(intent);

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

From source file:Main.java

public static void openActivity(Context context, Class<?> clazz, Bundle... bundles) {
    Intent intent = new Intent(context, clazz);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if (bundles != null && bundles.length > 0) {
        intent.putExtras(bundles[0]);/*  w  ww .  j av  a 2 s .  c  o m*/
    }
    context.startActivity(intent);
}

From source file:Main.java

public static void openBrowserInNewTask(Context context, String url) {
    context.startActivity(/*from   www. ja va  2 s  .  com*/
            new Intent(Intent.ACTION_VIEW, Uri.parse(url)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}

From source file:Main.java

public static void pickImageFromPhoto(Activity activity, int requestCode) {

    Intent intent = new Intent(Intent.ACTION_PICK, null);
    intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
    activity.startActivityForResult(intent, requestCode);

}