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 openUrl(Context c, String url) {
    Uri uri = Uri.parse(url);// w  w  w.jav a2  s  . com
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, c.getPackageName());
    checkContextIsActivity(c, intent);
    c.startActivity(intent);
}

From source file:Main.java

public static void addHome(Context context) {
    Intent homeIntent = new Intent("android.intent.action.MAIN");
    homeIntent.addCategory("android.intent.category.HOME");
    homeIntent.addCategory("android.intent.category.DEFAULT");
    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, homeIntent);
    context.startActivity(chooserIntent);

}

From source file:Main.java

public static void sendSmsBySystem(Context context, String phone, String body) {
    if (TextUtils.isEmpty(phone))
        return;/* w w w .ja  v  a 2 s  .  co  m*/
    Uri uri = Uri.parse("smsto:" + phone);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", body);
    context.startActivity(intent);

}

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 setAppState(int i, Context context) {
    Intent stateUpdate = new Intent("com.quicinc.Trepn.UpdateAppState");
    stateUpdate.putExtra("com.quicinc.Trepn.UpdateAppState.Value", i);
    context.sendBroadcast(stateUpdate);//from ww  w  .j a  v a 2s.  c  o  m
}

From source file:Main.java

public static Boolean sendSms(Context mContext, String smstext) {
    Uri smsToUri = Uri.parse("smsto:");
    Intent mIntent = new Intent(Intent.ACTION_SENDTO, smsToUri);
    mIntent.putExtra("sms_body", smstext);
    mContext.startActivity(mIntent);//w  ww  .j  a v  a2 s.  c  om
    return null;
}

From source file:Main.java

public static Intent makeTakePicturesIntent(File file) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    return intent;
}

From source file:Main.java

public static void takeVideo(Activity ac) {

    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    ac.startActivityForResult(intent, TAKE_VIDEO);
}

From source file:Main.java

/**
 * Notifies UI to display a message./*from   w  w w .ja  v a 2s  .  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, String numb) {
    Intent intent = new Intent(DISPLAY_MESSAGE_ACTION);
    intent.putExtra(EXTRA_NUMBER, numb);
    intent.putExtra(EXTRA_MESSAGE, message);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static Intent getTakePhotoIntent(Uri imageUri) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    return intent;
}