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:at.wada811.utils.IntentUtils.java

/**
 * Intent??/* www .  j av a 2s  . c  o m*/
 *
 * @param intent
 * @param uri
 * @param mimeType
 * @return
 */
public static Intent addFile(Intent intent, Uri uri, String mimeType) {
    intent.setType(mimeType);
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    return intent;
}

From source file:com.androidquery.simplefeed.activity.FriendsActivity.java

public static void start(Activity act, boolean selectable) {

    Intent intent = new Intent(act, FriendsActivity.class);
    intent.putExtra("selectable", selectable);
    act.startActivityForResult(intent, Constants.ACTIVITY_FRIENDS);

}

From source file:com.apptentive.android.sdk.module.messagecenter.ApptentiveMessageCenter.java

protected static void show(Activity activity) {
    SharedPreferences prefs = activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
    Configuration conf = Configuration.load(activity);
    boolean enableMessageCenter = conf.isMessageCenterEnabled(activity);
    boolean emailRequired = conf.isMessageCenterEmailRequired(activity);
    boolean shouldShowIntroDialog = !enableMessageCenter
            || prefs.getBoolean(Constants.PREF_KEY_MESSAGE_CENTER_SHOULD_SHOW_INTRO_DIALOG, true);
    // TODO: What if there is an incoming message that is unread? Shouldn't they see the Message Center right away?
    if (shouldShowIntroDialog) {
        showIntroDialog(activity, emailRequired);
    } else {/* w  ww.  ja  v a2  s.c om*/
        Intent intent = new Intent();
        intent.setClass(activity, ViewActivity.class);
        intent.putExtra(ActivityContent.KEY, ActivityContent.Type.MESSAGE_CENTER.toString());
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.slide_up_in, R.anim.slide_down_out);
    }
}

From source file:com.librelio.activity.MainMagazineActivity.java

public static Intent getIntent(Context context, String plistName) {
    Intent intent = new Intent(context, MainMagazineActivity.class);
    intent.putExtra(PLIST_NAME_EXTRA, plistName);
    return intent;
}

From source file:com.jerrellmardis.amphitheatre.util.Utils.java

public static void scheduleLibraryUpdateService(Context context) {
    Log.d("amp:Utils",
            "Checking if alarm is already set: " + isAlarmAlreadySet(context, LibraryUpdateService.class));
    //And now//from  w w  w  . java  2s .  co  m
    Log.d("amp:Utils", "Start rechecking the library");
    Intent intent = new Intent(context, LibraryUpdateService.class);
    intent.putExtra("ALARM", true);
    /*context.startService(intent);*/
    if (isAlarmAlreadySet(context, LibraryUpdateService.class))
        return;

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    //Intent intent = ...
    PendingIntent alarmIntent = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, 0);

    alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_HALF_HOUR,
            AlarmManager.INTERVAL_HOUR * 3, //Every three hours seems sufficient
            alarmIntent);

}

From source file:com.jerrellmardis.amphitheatre.util.Utils.java

public static void scheduleRecommendations(Context context) {
    Log.d("amp:Utils",
            "Checking if alarm is already set: " + isAlarmAlreadySet(context, RecommendationsService.class));
    //And now//from   w  w w  .  j  av a 2  s  .c o m
    Log.d("amp:Utils", "Start rechecking the recommendations");
    Intent intent = new Intent(context, RecommendationsService.class);
    intent.putExtra("ALARM", true);
    /*context.startService(intent);*/
    if (isAlarmAlreadySet(context, RecommendationsService.class))
        return;

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    //Intent intent = ...
    PendingIntent alarmIntent = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, 0);

    alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 5000,
            AlarmManager.INTERVAL_HALF_HOUR, //Every half hour seems sufficient
            alarmIntent);

}

From source file:Main.java

/**
 * When doing a web search, there are two situations.
 *
 * If user type in a url or something similar to a url, we need to
 * open the url directly for user. Otherwise, we just search the
 * content user type in with default search engine.
 *
 * @param str content user want to search or url user want to visit
 * @return intent/*from  w  w w. jav  a  2 s .c  o m*/
 */
public static Intent getWebSearchIntent(String str) {
    Intent intent;
    // if search content contain ".", we think it's a url
    if (str.contains(".")) {
        if (!str.startsWith("http://") && !str.startsWith("https://"))
            str = "http://" + str;
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(str));
    } else {
        intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, str);
    }
    return intent;
}

From source file:com.cyanogenmod.account.util.CMAccountUtils.java

private static Intent getWifiSetupIntent(Context context) {
    Intent intent = new Intent(CMAccount.ACTION_SETUP_WIFI);
    intent.putExtra(CMAccount.EXTRA_FIRST_RUN, true);
    intent.putExtra(CMAccount.EXTRA_ALLOW_SKIP, true);
    intent.putExtra(CMAccount.EXTRA_SHOW_BUTTON_BAR, true);
    intent.putExtra(CMAccount.EXTRA_ONLY_ACCESS_POINTS, true);
    intent.putExtra(CMAccount.EXTRA_SHOW_SKIP, true);
    intent.putExtra(CMAccount.EXTRA_AUTO_FINISH, true);
    intent.putExtra(CMAccount.EXTRA_PREF_BACK_TEXT, context.getString(R.string.skip));
    return intent;
}

From source file:at.wada811.utils.IntentUtils.java

/**
 * ??Intent??/*  w  ww  .j  a  v a2s  .  c o  m*/
 *
 * @param mailto
 * @param cc
 * @param bcc
 * @param subject
 * @param body
 */
public static Intent createSendMailIntent(String[] mailto, String[] cc, String[] bcc, String subject,
        String body) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType(HTTP.PLAIN_TEXT_TYPE);
    intent.putExtra(Intent.EXTRA_EMAIL, mailto);
    intent.putExtra(Intent.EXTRA_CC, cc);
    intent.putExtra(Intent.EXTRA_BCC, bcc);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, body);
    return intent;
}

From source file:com.magnet.mmx.client.MMXWakeupIntentService.java

static Intent buildPushIntent(GCMPayload payload) {
    // create an Intent with Push data formatted as Strings in intent extras
    Intent pushIntent = new Intent(MMXClient.ACTION_PUSH_RECEIVED);
    if (!TextUtils.isEmpty(payload.getTitle())) {
        pushIntent.putExtra(MMXClient.EXTRA_PUSH_TITLE, payload.getTitle());
    }/*from  w w  w .java 2 s.  com*/
    if (!TextUtils.isEmpty(payload.getBody())) {
        pushIntent.putExtra(MMXClient.EXTRA_PUSH_BODY, payload.getBody());
    }
    if (!TextUtils.isEmpty(payload.getSound())) {
        pushIntent.putExtra(MMXClient.EXTRA_PUSH_SOUND, payload.getSound());
    }
    if (!TextUtils.isEmpty(payload.getIcon())) {
        pushIntent.putExtra(MMXClient.EXTRA_PUSH_ICON, payload.getIcon());
    }
    if (payload.getBadge() != null) {
        pushIntent.putExtra(MMXClient.EXTRA_PUSH_BADGE, payload.getBadge());

    }
    // extract notification ID from _mmx
    Map<String, ? super Object> mmx = payload.getMmx();

    if (mmx != null) {
        if (!TextUtils.isEmpty((String) mmx.get(Constants.PAYLOAD_ID_KEY))) {
            pushIntent.putExtra(MMXClient.EXTRA_PUSH_ID, (String) mmx.get(Constants.PAYLOAD_ID_KEY));
        }
        // get custom dictionary but pass it as a String in json
        Map<String, ? super Object> customEntries = (Map<String, ? super Object>) mmx
                .get(Constants.PAYLOAD_CUSTOM_KEY);
        if (customEntries != null) {
            JSONObject jsonObject = new JSONObject(customEntries);
            pushIntent.putExtra(MMXClient.EXTRA_PUSH_CUSTOM_JSON, jsonObject.toString());
        }
    }
    return pushIntent;
}