Example usage for android.os Bundle putInt

List of usage examples for android.os Bundle putInt

Introduction

In this page you can find the example usage for android.os Bundle putInt.

Prototype

public void putInt(@Nullable String key, int value) 

Source Link

Document

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java

@Override
public void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);

    if (mTwitterStatusIdWhenRefreshed != null)
        state.putLong("TwitterStatusIdWhenRefreshed", mTwitterStatusIdWhenRefreshed);

    if (mLastTwitterStatusIdSeen != null)
        state.putLong("LastTwitterStatusIdSeen", mLastTwitterStatusIdSeen);

    state.putInt("NewStatuses", mNewStatuses);
    state.putBoolean("HidingListHeading", mHidingListHeading);

    mSelectedItems.clear();/*from  w w w .  j a v a 2  s.c  o m*/
    android.util.SparseBooleanArray items = mTweetFeedListView.getRefreshableView().getCheckedItemPositions();
    for (int i = 0; i < items.size(); i++) {
        int key = items.keyAt(i);
        mTweetFeedListView.getRefreshableView().setItemChecked(key, false);
    }

}

From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java

@Override
protected void onSaveInstanceState(Bundle b) {
    super.onSaveInstanceState(b);
    b.putSerializable("historyFilterDevices", historyFilterDevices);
    b.putSerializable("historyFilterNetworks", historyFilterNetworks);
    b.putSerializable("historyFilterDevicesFilter", historyFilterDevicesFilter);
    b.putSerializable("historyFilterNetworksFilter", historyFilterNetworksFilter);
    b.putSerializable("historyItemList", historyItemList);
    b.putSerializable("historyStorageList", historyStorageList);
    b.putInt("historyResultLimit", historyResultLimit);
    b.putSerializable("currentMapOptions", currentMapOptions);
    b.putSerializable("currentMapOptionTitles", currentMapOptionTitles);
    b.putSerializable("mapTypeListSectionList", mapTypeListSectionList);
    b.putSerializable("mapFilterListSectionListMap", mapFilterListSectionListMap);
    b.putSerializable("currentMapType", currentMapType);

}

From source file:com.android.exchange.EasSyncService.java

/**
 * Use the Exchange 2007 AutoDiscover feature to try to retrieve server information using
 * only an email address and the password
 *
 * @param userName the user's email address
 * @param password the user's password//from  ww w .ja va 2 s .  c o  m
 * @return a HostAuth ready to be saved in an Account or null (failure)
 */
public Bundle tryAutodiscover(String userName, String password) throws RemoteException {
    XmlSerializer s = Xml.newSerializer();
    ByteArrayOutputStream os = new ByteArrayOutputStream(1024);
    HostAuth hostAuth = new HostAuth();
    Bundle bundle = new Bundle();
    bundle.putInt(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_ERROR_CODE, MessagingException.NO_ERROR);
    try {
        // Build the XML document that's sent to the autodiscover server(s)
        s.setOutput(os, "UTF-8");
        s.startDocument("UTF-8", false);
        s.startTag(null, "Autodiscover");
        s.attribute(null, "xmlns", AUTO_DISCOVER_SCHEMA_PREFIX + "requestschema/2006");
        s.startTag(null, "Request");
        s.startTag(null, "EMailAddress").text(userName).endTag(null, "EMailAddress");
        s.startTag(null, "AcceptableResponseSchema");
        s.text(AUTO_DISCOVER_SCHEMA_PREFIX + "responseschema/2006");
        s.endTag(null, "AcceptableResponseSchema");
        s.endTag(null, "Request");
        s.endTag(null, "Autodiscover");
        s.endDocument();
        String req = os.toString();

        // Initialize the user name and password
        mUserName = userName;
        mPassword = password;
        // Make sure the authentication string is recreated and cached
        cacheAuthAndCmdString();

        // Split out the domain name
        int amp = userName.indexOf('@');
        // The UI ensures that userName is a valid email address
        if (amp < 0) {
            throw new RemoteException();
        }
        String domain = userName.substring(amp + 1);

        // There are up to four attempts here; the two URLs that we're supposed to try per the
        // specification, and up to one redirect for each (handled in postAutodiscover)
        // Note: The expectation is that, of these four attempts, only a single server will
        // actually be identified as the autodiscover server.  For the identified server,
        // we may also try a 2nd connection with a different format (bare name).

        // Try the domain first and see if we can get a response
        HttpPost post = new HttpPost("https://" + domain + AUTO_DISCOVER_PAGE);
        setHeaders(post, false);
        post.setHeader("Content-Type", "text/xml");
        post.setEntity(new StringEntity(req));
        HttpClient client = getHttpClient(COMMAND_TIMEOUT);
        HttpResponse resp;
        try {
            resp = postAutodiscover(client, post, true /*canRetry*/);
        } catch (IOException e1) {
            userLog("IOException in autodiscover; trying alternate address");
            // We catch the IOException here because we have an alternate address to try
            post.setURI(URI.create("https://autodiscover." + domain + AUTO_DISCOVER_PAGE));
            // If we fail here, we're out of options, so we let the outer try catch the
            // IOException and return null
            resp = postAutodiscover(client, post, true /*canRetry*/);
        }

        // Get the "final" code; if it's not 200, just return null
        int code = resp.getStatusLine().getStatusCode();
        userLog("Code: " + code);
        if (code != HttpStatus.SC_OK)
            return null;

        // At this point, we have a 200 response (SC_OK)
        HttpEntity e = resp.getEntity();
        InputStream is = e.getContent();
        try {
            // The response to Autodiscover is regular XML (not WBXML)
            // If we ever get an error in this process, we'll just punt and return null
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            XmlPullParser parser = factory.newPullParser();
            parser.setInput(is, "UTF-8");
            int type = parser.getEventType();
            if (type == XmlPullParser.START_DOCUMENT) {
                type = parser.next();
                if (type == XmlPullParser.START_TAG) {
                    String name = parser.getName();
                    if (name.equals("Autodiscover")) {
                        hostAuth = new HostAuth();
                        parseAutodiscover(parser, hostAuth);
                        // On success, we'll have a server address and login
                        if (hostAuth.mAddress != null) {
                            // Fill in the rest of the HostAuth
                            // We use the user name and password that were successful during
                            // the autodiscover process
                            hostAuth.mLogin = mUserName;
                            hostAuth.mPassword = mPassword;
                            hostAuth.mPort = 443;
                            hostAuth.mProtocol = "eas";
                            hostAuth.mFlags = HostAuth.FLAG_SSL | HostAuth.FLAG_AUTHENTICATE;
                            bundle.putParcelable(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_HOST_AUTH, hostAuth);
                        } else {
                            bundle.putInt(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_ERROR_CODE,
                                    MessagingException.UNSPECIFIED_EXCEPTION);
                        }
                    }
                }
            }
        } catch (XmlPullParserException e1) {
            // This would indicate an I/O error of some sort
            // We will simply return null and user can configure manually
        }
        // There's no reason at all for exceptions to be thrown, and it's ok if so.
        // We just won't do auto-discover; user can configure manually
    } catch (IllegalArgumentException e) {
        bundle.putInt(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_ERROR_CODE,
                MessagingException.UNSPECIFIED_EXCEPTION);
    } catch (IllegalStateException e) {
        bundle.putInt(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_ERROR_CODE,
                MessagingException.UNSPECIFIED_EXCEPTION);
    } catch (IOException e) {
        userLog("IOException in Autodiscover", e);
        bundle.putInt(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_ERROR_CODE, MessagingException.IOERROR);
    } catch (MessagingException e) {
        bundle.putInt(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_ERROR_CODE,
                MessagingException.AUTHENTICATION_FAILED);
    }
    return bundle;
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openUserListDetails(final Activity activity, final long account_id, final int list_id,
        final long user_id, final String screen_name, final String list_name) {
    if (activity == null)
        return;//from w w  w .  j av a  2 s . com
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new UserListDetailsFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        args.putInt(INTENT_KEY_LIST_ID, list_id);
        args.putLong(INTENT_KEY_USER_ID, user_id);
        args.putString(INTENT_KEY_SCREEN_NAME, screen_name);
        args.putString(INTENT_KEY_LIST_NAME, list_name);
        fragment.setArguments(args);
        dual_pane_activity.showFragment(fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_LIST_DETAILS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        if (list_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(list_id));
        }
        if (user_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user_id));
        }
        if (screen_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screen_name);
        }
        if (list_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, list_name);
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openUserListMembers(final Activity activity, final long account_id, final int list_id,
        final long user_id, final String screen_name, final String list_name) {
    if (activity == null)
        return;//from  w ww. ja va  2s.co  m
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new UserListMembersFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        args.putInt(INTENT_KEY_LIST_ID, list_id);
        args.putLong(INTENT_KEY_USER_ID, user_id);
        args.putString(INTENT_KEY_SCREEN_NAME, screen_name);
        args.putString(INTENT_KEY_LIST_NAME, list_name);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_LIST_MEMBERS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        if (list_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(list_id));
        }
        if (user_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user_id));
        }
        if (screen_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screen_name);
        }
        if (list_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, list_name);
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openUserListSubscribers(final Activity activity, final long account_id, final int list_id,
        final long user_id, final String screen_name, final String list_name) {
    if (activity == null)
        return;/*from  w  w  w .  j  av  a2  s. co  m*/
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new UserListSubscribersFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        args.putInt(INTENT_KEY_LIST_ID, list_id);
        args.putLong(INTENT_KEY_USER_ID, user_id);
        args.putString(INTENT_KEY_SCREEN_NAME, screen_name);
        args.putString(INTENT_KEY_LIST_NAME, list_name);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_LIST_SUBSCRIBERS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        if (list_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(list_id));
        }
        if (user_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user_id));
        }
        if (screen_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screen_name);
        }
        if (list_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, list_name);
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openUserListTimeline(final Activity activity, final long account_id, final int list_id,
        final long user_id, final String screen_name, final String list_name) {
    if (activity == null)
        return;//from  w  w  w . j  av  a 2  s .co m
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new UserListTimelineFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        args.putInt(INTENT_KEY_LIST_ID, list_id);
        args.putLong(INTENT_KEY_USER_ID, user_id);
        args.putString(INTENT_KEY_SCREEN_NAME, screen_name);
        args.putString(INTENT_KEY_LIST_NAME, list_name);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_LIST_TIMELINE);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        if (list_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(list_id));
        }
        if (user_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user_id));
        }
        if (screen_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screen_name);
        }
        if (list_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, list_name);
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:cgeo.geocaching.CacheListActivity.java

@Override
public void onSaveInstanceState(final Bundle savedInstanceState) {
    // Always call the superclass so it can save the view hierarchy state
    super.onSaveInstanceState(savedInstanceState);

    // Save the current Filter
    savedInstanceState.putParcelable(STATE_FILTER, currentFilter);
    savedInstanceState.putBoolean(STATE_INVERSE_SORT, adapter.getInverseSort());
    savedInstanceState.putInt(STATE_LIST_TYPE, type.ordinal());
    savedInstanceState.putInt(STATE_LIST_ID, listId);
}

From source file:com.test.onesignal.GenerateNotificationRunner.java

@Test
public void shouldUpdateNormalNotificationDisplayWhenReplacingANotification() throws Exception {
    // Setup - init
    OneSignal.setInFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification);
    OneSignal.init(blankActivity, "123456789", "b2f7f966-d8cc-11e4-bed1-df8f05be55ba");
    threadAndTaskWait();//from  w w  w  .j  a v  a2  s .c o  m

    // Setup - Display 2 notifications with the same group and collapse_id
    Bundle bundle = getBaseNotifBundle("UUID1");
    bundle.putString("grp", "test1");
    bundle.putString("collapse_key", "1");
    NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, bundle, null);

    bundle = getBaseNotifBundle("UUID2");
    bundle.putString("grp", "test1");
    bundle.putString("collapse_key", "1");
    NotificationBundleProcessor_ProcessFromGCMIntentService(blankActivity, bundle, null);

    // Test - Summary created and sub notification. Summary will look the same as the normal notification.
    Map<Integer, PostedNotification> postedNotifs = ShadowRoboNotificationManager.notifications;
    Iterator<Map.Entry<Integer, PostedNotification>> postedNotifsIterator = postedNotifs.entrySet().iterator();
    Assert.assertEquals(2, postedNotifs.size());
    PostedNotification postedSummaryNotification = postedNotifsIterator.next().getValue();
    Assert.assertEquals(notifMessage, postedSummaryNotification.getShadow().getContentText());
    Assert.assertEquals(Notification.FLAG_GROUP_SUMMARY,
            postedSummaryNotification.notif.flags & Notification.FLAG_GROUP_SUMMARY);

    int lastNotifId = postedNotifsIterator.next().getValue().id;
    ShadowRoboNotificationManager.notifications.clear();

    // Setup - Restore
    bundle = getBaseNotifBundle("UUID2");
    bundle.putString("grp", "test1");
    bundle = createInternalPayloadBundle(bundle);
    bundle.putInt("android_notif_id", lastNotifId);
    bundle.putBoolean("restoring", true);
    NotificationBundleProcessor_ProcessFromGCMIntentService_NoWrap(blankActivity, bundle, null);

    // Test - Restored notifications display exactly the same as they did when recevied.
    postedNotifs = ShadowRoboNotificationManager.notifications;
    postedNotifsIterator = postedNotifs.entrySet().iterator();
    // Test - 1 notifi + 1 summary
    Assert.assertEquals(2, postedNotifs.size());
    Assert.assertEquals(notifMessage, postedSummaryNotification.getShadow().getContentText());
    Assert.assertEquals(Notification.FLAG_GROUP_SUMMARY,
            postedSummaryNotification.notif.flags & Notification.FLAG_GROUP_SUMMARY);
}

From source file:fr.cobaltians.cobalt.Cobalt.java

private Bundle getConfigurationForController(String controller) {
    Bundle bundle = new Bundle();

    JSONObject configuration = getConfiguration();

    // Gets configuration
    try {/*from  w  ww .  j a  v a 2s. c  om*/
        JSONObject controllers = configuration.getJSONObject(kControllers);

        String activity;
        // TODO: uncomment for Bars
        //JSONObject actionBar;
        boolean enablePullToRefresh;
        boolean enableInfiniteScroll;
        int infiniteScrollOffset;
        // TODO: add enableGesture

        if (controller != null && controllers.has(controller)) {
            activity = controllers.getJSONObject(controller).getString(kAndroid);
            //actionBar = controllers.getJSONObject(controller).optJSONObject(kBars);
            enablePullToRefresh = controllers.getJSONObject(controller).optBoolean(kPullToRefresh);
            enableInfiniteScroll = controllers.getJSONObject(controller).optBoolean(kInfiniteScroll);
            infiniteScrollOffset = controllers.getJSONObject(controller).optInt(kInfiniteScrollOffset,
                    INFINITE_SCROLL_OFFSET_DEFAULT_VALUE);
        } else {
            activity = controllers.getJSONObject(kDefaultController).getString(kAndroid);
            //actionBar = controllers.getJSONObject(kDefaultController).optJSONObject(kBars);
            enablePullToRefresh = controllers.getJSONObject(kDefaultController).optBoolean(kPullToRefresh);
            enableInfiniteScroll = controllers.getJSONObject(kDefaultController).optBoolean(kInfiniteScroll);
            infiniteScrollOffset = controllers.getJSONObject(kDefaultController).optInt(kInfiniteScrollOffset,
                    INFINITE_SCROLL_OFFSET_DEFAULT_VALUE);
        }

        bundle.putString(kActivity, activity);
        //if (actionBar != null) bundle.putString(kBars, actionBar.toString());
        bundle.putBoolean(kPullToRefresh, enablePullToRefresh);
        bundle.putBoolean(kInfiniteScroll, enableInfiniteScroll);
        bundle.putInt(kInfiniteScrollOffset, infiniteScrollOffset);

        return bundle;
    } catch (JSONException exception) {
        if (Cobalt.DEBUG)
            Log.e(Cobalt.TAG,
                    TAG + " - getConfigurationForController: check cobalt.conf. Known issues: \n "
                            + "\t - controllers field not found or not a JSONObject \n " + "\t - " + controller
                            + " controller not found and no " + kDefaultController + " controller defined \n "
                            + "\t - " + controller + " or " + kDefaultController + "controller found but no "
                            + kAndroid + "defined \n ");
        exception.printStackTrace();
    }

    return bundle;
}