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 gotoActivity(Context ctx, Class<?> c, String key, String value) {
    Intent intent = new Intent(ctx, c);
    intent.putExtra(key, value);
    ctx.startActivity(intent);/* w  ww . j a v a  2 s. com*/
}

From source file:Main.java

/**
 * get ringtone list/*w ww  . j  a va2 s. c o  m*/
 * @return
 */
public static Intent getRingtoneIntent() {
    Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
    intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);

    return intent;
}

From source file:Main.java

public static void setBadgeOfMadMode(Context context, int count, String packageName, String className) {
    Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
    intent.putExtra("badge_count", count);
    intent.putExtra("badge_count_package_name", packageName);
    intent.putExtra("badge_count_class_name", className);
    context.sendBroadcast(intent);/*w ww. j ava  2  s .  c o m*/
}

From source file:Main.java

public static Intent createSmsToIntent(String text) {
    Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:"));
    sendIntent.putExtra("sms_body", text);
    return sendIntent;
}

From source file:Main.java

/***
 * Constructs an intent for capturing a photo and storing it in a temporary
 * file./*from   w w  w. j av a2s. c o  m*/
 */
public static Intent getTakePickIntent(File f) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
    return intent;
}

From source file:Main.java

private static void sendBroadcastFile(Context context, String filepath, double progress) {
    Intent intent = new Intent();
    intent.setAction("file_receiver");
    intent.putExtra("path", filepath);
    intent.putExtra("progress", progress);
    context.sendBroadcast(intent);/*from  w w w .  j a va2  s  . c o m*/
}

From source file:Main.java

public static final void sendToDeleteSearchResultItemData(Context context, String time) {
    Intent intent = new Intent();
    intent.setAction(HOMELIST_DELETE);/*  w  w w  . j  av  a 2s . c o  m*/
    intent.putExtra(SEARCH_TIME, time);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static void UnRegister(Context context) {
    Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
    unregIntent.putExtra("app", PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    context.startService(unregIntent);// w  w w. ja  v a2 s.co m
}

From source file:Main.java

public static Intent getShareImageIntent(Uri uri) {
    Intent image = new Intent();
    image.setAction(Intent.ACTION_SEND);
    image.putExtra(Intent.EXTRA_STREAM, uri);
    image.setType("image/*");
    return image;
}

From source file:Main.java

public static void startSmsIntent(Context context, String phoneNumber) {
    try {// ww w  .  j av a 2 s . co  m
        Uri uri = Uri.parse("sms:" + phoneNumber);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.putExtra("address", phoneNumber);
        intent.setType("vnd.android-dir/mms-sms");
        context.startActivity(intent);
    } catch (Exception ex) {
        Log.e(TAG, "Error starting sms intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app to send an SMS!", Toast.LENGTH_SHORT).show();
    }
}