Example usage for android.content Intent putExtra

List of usage examples for android.content Intent putExtra

Introduction

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

Prototype

@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value) 

Source Link

Document

Add extended data to the intent.

Usage

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 Intent sendEmail(String[] to, String subject, String body) {
    final Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_EMAIL, to);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, body);
    return intent;
}

From source file:Main.java

public static void sharePic(Uri uri, String desc, Context context) {

    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
    shareIntent.setType("image/jpeg");
    context.startActivity(Intent.createChooser(shareIntent, desc));
}

From source file:Main.java

public static void shareFile(Context context, String title, String subject, String text, String mime,
        String path) {/*from w  w w.  j a va2 s .com*/
    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType(mime);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path));
    sendIntent.putExtra(Intent.EXTRA_TEXT, text);
    context.startActivity(Intent.createChooser(sendIntent, title));
}

From source file:Main.java

public static void editMessage(Context context, String msg) {
    Intent msgIntent = new Intent();
    msgIntent.setAction(Intent.ACTION_SENDTO);
    msgIntent.putExtra("sms_body", msg);
    context.startActivity(msgIntent);// ww  w .  ja v  a  2  s. c om
}

From source file:Main.java

public static void resultSetParameter(Activity context, int resultCode, String extraName, String extraValue) {
    Intent intent = new Intent();
    intent.putExtra(extraName, extraValue);
    context.setResult(resultCode, intent);
}

From source file:Main.java

public static void resultSetParameter(Activity context, int resultCode, String extraName, int extraValue) {
    Intent intent = new Intent();
    intent.putExtra(extraName, extraValue);
    context.setResult(resultCode, intent);
}

From source file:Main.java

public static void resultSetParameter(Activity context, int resultCode, String extraName, int[] extraValue) {
    Intent intent = new Intent();
    intent.putExtra(extraName, extraValue);
    context.setResult(resultCode, intent);
}

From source file:Main.java

public static void resultSetParameter(Activity context, int resultCode, String extraName, double extraValue) {
    Intent intent = new Intent();
    intent.putExtra(extraName, extraValue);
    context.setResult(resultCode, intent);
}

From source file:Main.java

public static void resultSetParameter(Activity context, int resultCode, String extraName, double[] extraValue) {
    Intent intent = new Intent();
    intent.putExtra(extraName, extraValue);
    context.setResult(resultCode, intent);
}