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 toTakePicture(int requestcode, Activity activity) {
    Intent intent = new Intent(Intent.ACTION_PICK, null);
    intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
    activity.startActivityForResult(intent, requestcode);
}

From source file:Main.java

public static void startActivityAndFinish(Context mContext, Class<?> T) {
    Intent intent = new Intent(mContext, T);
    mContext.startActivity(intent);//from  w ww  .  ja v  a  2s.  com
    ((Activity) mContext).finish();
}

From source file:Main.java

public static void startActivity(Context c, Class clz, boolean ifFinish) {
    Intent intent = new Intent(c, clz);
    c.startActivity(intent);/*from  ww  w .  jav a 2  s  .c  o  m*/
    if (ifFinish) {
        ((Activity) c).finish();
    }

}

From source file:Main.java

public static void allScan(Context context) {
    context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
            Uri.parse("file://" + Environment.getExternalStorageDirectory())));
}

From source file:Main.java

public static void openPost(Context context, String postUrl) {
    try {/*from www .  jav a  2s. co m*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(postUrl));
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void startActivityForStringData(Activity activity, String name, Class<?> cls, String data) {
    Intent intent = new Intent(activity, cls);
    intent.putExtra(name, data);//  ww w.  j a  v a2  s  . com
    activity.startActivity(intent);
}

From source file:Main.java

public static void startActivity(Context context, Class<? extends Activity> clazz) {
    Intent intent = new Intent(context, clazz);
    context.startActivity(intent);/*from  ww w .  j av  a2s .  co m*/
}

From source file:Main.java

public static void startActivity(Context context, Class<? extends Activity> target) {
    Intent intent = new Intent(context, target);
    context.startActivity(intent);/*  ww  w  .  j  a v  a2s  .  com*/
}

From source file:Main.java

public static void toNextActivityAndFinish(Context packageContext, Class<?> cls) {
    Intent i = new Intent(packageContext, cls);
    packageContext.startActivity(i);/*from w ww .  j  a  v  a2s  .  c om*/

    ((Activity) packageContext).finish();
}

From source file:Main.java

public static void startSystemGallery(Activity activity, int resultCode) {
    Intent intent1 = new Intent(Intent.ACTION_PICK, null);
    intent1.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
    activity.startActivityForResult(intent1, resultCode);
}