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 sendSMS(Context context, String number, String message) {
    Uri uri = Uri.parse("smsto:" + number);

    Intent sendIntent = new Intent(Intent.ACTION_VIEW, uri);
    sendIntent.putExtra("sms_body", message);

    context.startActivity(sendIntent);/*from   w w w  .  j  av a2 s . c  o m*/
}

From source file:Main.java

public static void sendMsg(Context context, String sentTo) {
    Uri smsToUri = Uri.parse("smsto:" + sentTo);
    Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);
    intent.putExtra("sms_body", "");
    context.startActivity(intent);//from ww w  .ja v a2s.c  o m
}

From source file:Main.java

public static Intent takePicture(Uri uri) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    return intent;
}

From source file:Main.java

@NonNull
public static Intent search(@NonNull String query) {
    final Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, query);
    return intent;
}

From source file:Main.java

public synchronized static void sendMessage(Context context, String Message) {
    Intent intent = new Intent("MainActivity");
    // add data/*  w w w . j  a v a2 s .c  o  m*/
    intent.putExtra("Message", Message);
    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}

From source file:Main.java

public static void callSystemSmsAction(Context context, String phone, String content) {
    Uri uri = Uri.parse("smsto:" + (TextUtils.isEmpty(phone) ? "" : phone));
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", TextUtils.isEmpty(content) ? "" : content);
    context.startActivity(intent);//  ww w.jav a 2  s .  c om
}

From source file:Main.java

static public void changeStatusIcon(Context context, int iconResID) {
    Intent intent = new Intent("at.sprinternet.odm.STATUS_CHANGED");
    intent.putExtra("statusImageID", iconResID);
    context.sendBroadcast(intent);/*  www .  ja  v  a  2 s  .  c  o  m*/
}

From source file:Main.java

public static void sendSmsByPhoneAndContext(Context context, String phone, String content) {
    phone = TextUtils.isEmpty(phone) ? "" : phone;
    content = TextUtils.isEmpty(content) ? "" : content;

    Uri uri = Uri.parse("smsto:" + phone);
    Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
    intent.putExtra("sms_body", content);
    context.startActivity(intent);//from  www  .j  av  a2s  . c o m
}

From source file:Main.java

public static void pauseAudioPlayback() {
    Intent i = new Intent("com.android.music.musicservicecommand");
    i.putExtra("command", "pause");
    context.sendBroadcast(i);/*from w  w w .  j a va  2  s. co m*/
}

From source file:Main.java

public static void takePhoto(Activity activity, int requestCode, Uri uri) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    activity.startActivityForResult(intent, requestCode);
}