Example usage for android.content Intent createChooser

List of usage examples for android.content Intent createChooser

Introduction

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

Prototype

public static Intent createChooser(Intent target, CharSequence title) 

Source Link

Document

Convenience function for creating a #ACTION_CHOOSER Intent.

Usage

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 Intent pickImage(int PICK_IMAGE) {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    intent.setAction(Intent.ACTION_GET_CONTENT);
    return Intent.createChooser(intent, "Select Picture");
}

From source file:Main.java

public static void selectImage(Activity activity, int i) {
    Intent intent = new Intent("android.intent.action.GET_CONTENT");
    intent.setType("image/*");
    activity.startActivityForResult(Intent.createChooser(intent, activity.getString(0x7f080083)), i);
}

From source file:Main.java

public static void openSourceURL(Activity activity, String title, String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = Uri.parse(url);//  www .j a  va2  s.c om
    intent.setData(uri);
    activity.startActivity(Intent.createChooser(intent, title));
}

From source file:Main.java

public static Intent getAndroidImageShareIntent(CharSequence chooseTitle, String pathfile) {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/*");
    share.putExtra(Intent.EXTRA_STREAM, Uri.parse(pathfile));
    return Intent.createChooser(share, chooseTitle);
}

From source file:Main.java

public static void share(Context context, String title, String url) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, url);
    Intent chooserIntent = Intent.createChooser(shareIntent, title);
    chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(chooserIntent);
}

From source file:Main.java

public static void shareText(Activity activity, String title, String text) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    sendIntent.setType("text/plain");
    activity.startActivity(Intent.createChooser(sendIntent, title));
}

From source file:Main.java

public static void shareImage(Context context, Uri uri, String title) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.setType("image/jpeg");
    context.startActivity(Intent.createChooser(shareIntent, title));
}

From source file:Main.java

public static void shareViaSms(Context context, String subject, String text) {
    Intent intent = new Intent();
    intent.setType("text/plain");
    intent.setData(Uri.parse("sms:"));
    intent.setAction(Intent.ACTION_VIEW);
    intent.putExtra("sms_body", text);
    context.startActivity(Intent.createChooser(intent, "Share via SMS"));
}

From source file:Main.java

public static void sendText(Activity context, String text) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    //        sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    //        sendIntent.setType("text/plain");
    context.startActivity(Intent.createChooser(sendIntent, text));
}