Example usage for android.content Intent setType

List of usage examples for android.content Intent setType

Introduction

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

Prototype

public @NonNull Intent setType(@Nullable String type) 

Source Link

Document

Set an explicit MIME data type.

Usage

From source file:Main.java

public static void shareText(Context context, String title, String text) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, title);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);// Intent.createChooser(intent, title)
}

From source file:Main.java

public static Intent createShareIntent(String title, String text) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("content/plain");
    intent.putExtra(Intent.EXTRA_TEXT, text);
    return Intent.createChooser(intent, title);
}

From source file:Main.java

public static void chooseFileIntent(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    activity.startActivityForResult(intent, FILE_PICK);
}

From source file:Main.java

public static void shareViaEmail(Context context, String subject, String text) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType("text/html");
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    context.startActivity(Intent.createChooser(intent, "Share via Email"));
}

From source file:Main.java

public static void sendTo(Context ctx, String sendWhat) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, sendWhat);
    ctx.startActivity(shareIntent);//from   w  w w  .  j ava  2  s. c  om
}

From source file:Main.java

private static Intent pickVideoIntent() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("video/*"); // String VIDEO_UNSPECIFIED = "video/*";
    // Intent wrapperIntent = Intent.createChooser(innerIntent, null);
    return intent;
}

From source file:Main.java

public static void showSentEmailIntent(Context context, String subject, String body) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("message/rfc822");
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(Intent.EXTRA_TEXT, body);
    context.startActivity(emailIntent);// ww w  .ja  v a 2  s  .  c o m
}

From source file:Main.java

public static void jumpToSystemLocPickImageActivity(Activity activity, int requestCode) {
    Intent intent = null;
    intent = new Intent();
    intent.setType("image/*");
    intent.setAction("android.intent.action.GET_CONTENT");
    activity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

static Intent makeShareIntent(String subject, String text) {
    final Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);
    return intent;
}

From source file:Main.java

public static void showPhoneContact(Activity activity, int returnCode) {
    if (activity == null)
        return;//  w  w  w.j  ava2 s . c om

    Intent intent = new Intent(Intent.ACTION_PICK);
    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    activity.startActivityForResult(intent, returnCode);
}