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 void pickRing(Activity activity) {
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select Tone");

    if (mRingUri != null) {
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, mRingUri);
    } else {/*from w  w w  .  j  a  v  a2  s  .  c  om*/
        intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
    }
    activity.startActivityForResult(intent, RESULT_PICK_RING);
}

From source file:Main.java

public static Intent getShareHtmlIntent(String htmlText) {
    Intent textIntent = new Intent();
    textIntent.setAction(Intent.ACTION_SEND);
    textIntent.putExtra(Intent.EXTRA_TEXT, "This is html");
    textIntent.putExtra(Intent.EXTRA_HTML_TEXT, htmlText);
    textIntent.setType("text/plain");
    return textIntent;
}

From source file:Main.java

public static void sendMail(Context context, String email) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
    sendIntent.putExtra(Intent.EXTRA_TEXT, "");
    sendIntent.setType("text/plain");
    context.startActivity(sendIntent);/*from w  ww  . ja v  a 2  s.c om*/
}

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.
 */
static void displayMessage(Context context, String message) {
    Log.d("gcm", "msg: " + message);
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void enableDiscoverable(Context paramContext) {
    Intent localIntent = new Intent("android.bluetooth.adapter.action.REQUEST_DISCOVERABLE");
    localIntent.putExtra("android.bluetooth.adapter.extra.DISCOVERABLE_DURATION", 300);
    paramContext.startActivity(localIntent);
}

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

/**
 * Notifies UI to display a message./*from  ww w  .  j a  v a2  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) {
    Log.i("CommonUtilities", "================Inside DisplayMessege Method==============================");
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

/**
 * @brief      Get the intent to insert email into contact
 *
 * @par        Sync (or) Async:/*from  ww w .j  a va 2  s .c  o  m*/
 * This is a Synchronous function.
 *
 * @param [IN] email    Email address.\n
 * 
 * @return     
 *
 * @author     daiping.zhao
 * @since      1.0.0.0
 * @version    1.0.0.0
 * @par        Prospective Clients:
 * External Classes
 */
public static Intent doAddEmailToContact(String email) {
    Intent newIntent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
    newIntent.putExtra(Intents.Insert.EMAIL, email);
    return newIntent;
}

From source file:Main.java

public static Intent getShareInfoIntent(String info) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    return intent.putExtra(Intent.EXTRA_TEXT, info);
}

From source file:Main.java

/**
 * @brief      Get the add tel intent//from   ww w .  j  a va2  s .  co  m
 *
 * @par        Sync (or) Async:
 * This is a Synchronous function.
 *
 * @param [IN] telNumber    Tel number.\n
 * 
 * @return     
 *
 * @author     daiping.zhao
 * @since      1.0.0.0
 * @version    1.0.0.0
 * @par        Prospective Clients:
 * External Classes
 */
public static Intent doAddTelContact(String telNumber) {
    Intent newIntent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
    newIntent.putExtra(Intents.Insert.PHONE, telNumber);
    return newIntent;
}