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

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 callSms(Context context, String number, String content) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SENDTO);
    intent.putExtra("sms_body", content);
    intent.setData(Uri.parse(String.format("smsto:%s", number)));
    context.startActivity(intent);/*  w ww.j  a  va 2  s  . c om*/
}

From source file:Main.java

/**
 * Shortcut intent for icon on homescreen.
 * @param context Context used to create the intent.
 * @param url Url of the bookmark./*from   w  w w  . java  2 s  .  c  o  m*/
 * @return Intent for onclick action of the shortcut.
 */
public static Intent createShortcutIntent(Context context, String url) {
    Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    shortcutIntent.putExtra(REUSE_URL_MATCHING_TAB_ELSE_NEW_TAB, true);
    return shortcutIntent;
}

From source file:Main.java

/**
 * Notifies UI to display a message./*from  w w w . j av  a  2 s. c om*/
 * <p>
 * This method is defined in the common helper because it's used both by
 * the UI and the background service.
 *
 * @param context application's context.
 * @param message message to be displayed.
 */
static void displayMessage(Context context, String message) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * Notifies UI to display a message.//  w  w w.j  av a 2 s. c o  m
 * <p>
 * This method is defined in the common helper because it's used both by
 * the UI and the background service.
 *
 * @param context application's context.
 * @param message message to be displayed.
 */
public static void displayMessage(Context context, String message) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

private static void shareAct(Activity act, String fileName, String text) {

    Uri uri = null;/*from   w w  w . j a va2  s  . c o m*/

    try {
        FileInputStream input = act.openFileInput(fileName);
        Bitmap bitmap = BitmapFactory.decodeStream(input);
        uri = Uri.parse(MediaStore.Images.Media.insertImage(act.getContentResolver(), bitmap, null, null));
        input.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

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

From source file:Main.java

public static void broadcastMessage(Context context, String servername, String message) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_SERVER_NAME, servername);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);//www .j  ava2 s.  c o  m
}

From source file:Main.java

public static void turnPhotosWithCrop(Activity mContext, int requestCode) {
    Intent intent = new Intent(Intent.ACTION_PICK);
    intent.setType("image/*");
    intent.putExtra("return-data", true);
    mContext.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static void makeVisible(Context context, int durationSeconds) {
    Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
    discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, durationSeconds);
    context.startActivity(discoverableIntent);
}

From source file:Main.java

/**
 * Notifies UI to display a message.//w  w  w. j  a v a 2s  . c  om
 * <p>
 * This method is defined in the common helper because it's used both by the
 * UI and the background service.
 * 
 * @param context
 *            application's context.
 * @param message
 *            message to be displayed.
 */
static void displayMessage(Context context, String message) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra("message", message);

    context.sendBroadcast(intent);
}