Example usage for android.os Bundle putLong

List of usage examples for android.os Bundle putLong

Introduction

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

Prototype

public void putLong(@Nullable String key, long value) 

Source Link

Document

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

Usage

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 ww.j av a 2s.  com
    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;/*  ww w .  j  a  va2s .c o 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:com.dwdesign.tweetings.util.Utils.java

public static void openStatus(final Activity activity, final ParcelableStatus status) {
    if (activity == null || status == null)
        return;/*from  www.j  a  va  2s . c o  m*/
    final long account_id = status.account_id, status_id = status.status_id;
    final Bundle bundle = new Bundle();
    bundle.putParcelable(INTENT_KEY_STATUS, status);
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment details_fragment = dual_pane_activity.getDetailsFragment();
        if (details_fragment instanceof StatusFragment && details_fragment.isAdded()) {
            ((StatusFragment) details_fragment).displayStatus(status);
            dual_pane_activity.bringRightPaneToFront();
        } else {
            final Fragment fragment = new StatusFragment();
            final Bundle args = new Bundle(bundle);
            args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
            args.putLong(INTENT_KEY_STATUS_ID, status_id);
            fragment.setArguments(args);
            dual_pane_activity.showAtPane(DualPaneActivity.PANE_RIGHT, fragment, true);
        }
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_STATUS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        builder.appendQueryParameter(QUERY_PARAM_STATUS_ID, String.valueOf(status_id));
        final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());

        intent.putExtras(bundle);
        activity.startActivity(intent);
    }
}

From source file:com.androzic.MapActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.e(TAG, "onSaveInstanceState()");
    outState.putParcelable("lastKnownLocation", lastKnownLocation);
    outState.putLong("lastRenderTime", lastRenderTime);
    outState.putLong("lastMagnetic", lastMagnetic);
    outState.putLong("lastDim", lastDim);
    outState.putBoolean("lastGeoid", lastGeoid);

    outState.putInt("waypointSelected", waypointSelected);
    outState.putInt("routeSelected", routeSelected);
    outState.putLong("mapObjectSelected", mapObjectSelected);

    if (application.distanceOverlay != null) {
        outState.putDoubleArray("distAncor", application.distanceOverlay.getAncor());
    }/*  www .jav a2  s . c  o  m*/
}

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

public static void openDirectMessagesConversation(final Activity activity, final long account_id,
        final long conversation_id) {
    if (activity == null)
        return;//from  www. jav  a2 s  .c om
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment details_fragment = dual_pane_activity.getDetailsFragment();
        if (details_fragment instanceof DMConversationFragment && details_fragment.isAdded()) {
            ((DMConversationFragment) details_fragment).showConversation(account_id, conversation_id);
        } else {
            final Fragment fragment = new DMConversationFragment();
            final Bundle args = new Bundle();
            if (account_id > 0 && conversation_id > 0) {
                args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
                if (conversation_id > 0) {
                    args.putLong(INTENT_KEY_CONVERSATION_ID, conversation_id);
                }
            }
            fragment.setArguments(args);
            dual_pane_activity.showAtPane(PANE_RIGHT, fragment, true);
        }
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_DIRECT_MESSAGES_CONVERSATION);
        if (account_id > 0 && conversation_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
            if (conversation_id > 0) {
                builder.appendQueryParameter(QUERY_PARAM_CONVERSATION_ID, String.valueOf(conversation_id));
            }
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.ezeeideas.wordjam.BaseGameActivity.java

/**
 * Save the instance state of the current game to the bundle.  This is usually called when the 
 * user rotates the device screen while playing the game.  It can be called at any time the system
 * decides to "kill" the activity without user interaction where the activity is expected to
 * "restore" itself at some later point.
 *///  www.j  a  v a  2s . co  m
@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);

    //cancel the async task, if it's running
    if (mSetupGameAsyncTask != null && mSetupGameAsyncTask.getStatus() != AsyncTask.Status.FINISHED) {
        mSetupGameAsyncTask.cancel(true);

        mGameData = null;
    }

    savedInstanceState.putBoolean(Constants.KEY_IS_PLAY, mIsPlay);
    savedInstanceState.putBoolean(Constants.KEY_IS_NEW_GAME, mIsNewGame);
    savedInstanceState.putInt(Constants.KEY_GAME_NUM, mGameNumber);
    savedInstanceState.putInt(Constants.KEY_PLAY_TYPE, mPlayType);

    savedInstanceState.putInt(Constants.KEY_GAME_TYPE, mGameType);
    savedInstanceState.putInt(Constants.KEY_GAME_POINTS, mGamePoints);
    savedInstanceState.putInt(Constants.KEY_GAME_STATE, mGameState);
    savedInstanceState.putInt(Constants.KEY_GAME_HINTS_REMAINING, mGameHintsRemaining);
    savedInstanceState.putLong(Constants.KEY_GAME_DURATION, mGameTime);
    savedInstanceState.putLong(Constants.KEY_GAME_LAST_PLAYED, System.currentTimeMillis());

    if (mGameData != null) {
        //the game setup (via AsyncTask) already happened once, so generate current game state and save
        savedInstanceState.putString(Constants.KEY_GAME_DATA, generateGameData());
    } else {
        //the game setup never happened, so set game data to null so it is setup the next time it is restored
        savedInstanceState.putString(Constants.KEY_GAME_DATA, null);
    }

    if (mIsPlay) {
        savedInstanceState.putInt(Constants.KEY_LEVEL, mLevel);
        savedInstanceState.putInt(Constants.KEY_LEVEL_STATE, mLevelState);
        savedInstanceState.putInt(Constants.KEY_LEVEL_GAMES_REMAINING, mLevelGamesRemaining);
        savedInstanceState.putInt(Constants.KEY_LEVEL_HINTS_REMAINING, mLevelHintsRemaining);
        savedInstanceState.putInt(Constants.KEY_LEVEL_HINTS_EARNED, mLevelHintsEarned);
        savedInstanceState.putInt(Constants.KEY_LEVEL_NUM_GAMES, mNumGamesInLevel);
    } else {
        savedInstanceState.putInt(Constants.KEY_PRACTICE_TYPE, mPracticeType);
        savedInstanceState.putInt(Constants.PRACTICE_GAMES_COMPLETED, mPracticeGamesCompleted);
        savedInstanceState.putInt(Constants.PRACTICE_TIME_SPENT, mPracticeTimeSpent);
        savedInstanceState.putInt(Constants.PRACTICE_HINTS_USED, mPracticeHintsUsed);
        savedInstanceState.putInt(Constants.PRACTICE_POINTS_EARNED, mPracticePointsEarned);
    }
}

From source file:com.android.calendar.EventInfoFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(BUNDLE_KEY_EVENT_ID, mEventId);
    outState.putLong(BUNDLE_KEY_START_MILLIS, mStartMillis);
    outState.putLong(BUNDLE_KEY_END_MILLIS, mEndMillis);
    outState.putBoolean(BUNDLE_KEY_IS_DIALOG, mIsDialog);
    outState.putInt(BUNDLE_KEY_WINDOW_STYLE, mWindowStyle);
    outState.putBoolean(BUNDLE_KEY_DELETE_DIALOG_VISIBLE, mDeleteDialogVisible);
    outState.putInt(BUNDLE_KEY_CALENDAR_COLOR, mCalendarColor);
    outState.putBoolean(BUNDLE_KEY_CALENDAR_COLOR_INIT, mCalendarColorInitialized);
    outState.putInt(BUNDLE_KEY_ORIGINAL_COLOR, mOriginalColor);
    outState.putBoolean(BUNDLE_KEY_ORIGINAL_COLOR_INIT, mOriginalColorInitialized);
    outState.putInt(BUNDLE_KEY_CURRENT_COLOR, mCurrentColor);
    outState.putBoolean(BUNDLE_KEY_CURRENT_COLOR_INIT, mCurrentColorInitialized);
    outState.putInt(BUNDLE_KEY_CURRENT_COLOR_KEY, mCurrentColorKey);
    outState.putInt(BUNDLE_KEY_DELETE_DIALOG_CHOICE, mDeleteDialogChoice);

    // We'll need the temporary response for configuration changes.
    outState.putInt(BUNDLE_KEY_TENTATIVE_USER_RESPONSE, mTentativeUserSetResponse);
    if (mTentativeUserSetResponse != Attendees.ATTENDEE_STATUS_NONE && mEditResponseHelper != null) {
        outState.putInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, mEditResponseHelper.getWhichEvents());
    }/*w w w .ja v  a  2 s .  c  o m*/

    // Save the current response.
    int response;
    if (mAttendeeResponseFromIntent != Attendees.ATTENDEE_STATUS_NONE) {
        response = mAttendeeResponseFromIntent;
    } else {
        response = mOriginalAttendeeResponse;
    }
    outState.putInt(BUNDLE_KEY_ATTENDEE_RESPONSE, response);
    if (mUserSetResponse != Attendees.ATTENDEE_STATUS_NONE) {
        response = mUserSetResponse;
        outState.putInt(BUNDLE_KEY_USER_SET_ATTENDEE_RESPONSE, response);
        outState.putInt(BUNDLE_KEY_RESPONSE_WHICH_EVENTS, mWhichEvents);
    }

    // Save the reminders.
    mReminders = EventViewUtils.reminderItemsToReminders(mReminderViews, mReminderMinuteValues,
            mReminderMethodValues);
    int numReminders = mReminders.size();
    ArrayList<Integer> reminderMinutes = new ArrayList<Integer>(numReminders);
    ArrayList<Integer> reminderMethods = new ArrayList<Integer>(numReminders);
    for (ReminderEntry reminder : mReminders) {
        reminderMinutes.add(reminder.getMinutes());
        reminderMethods.add(reminder.getMethod());
    }
    outState.putIntegerArrayList(BUNDLE_KEY_REMINDER_MINUTES, reminderMinutes);
    outState.putIntegerArrayList(BUNDLE_KEY_REMINDER_METHODS, reminderMethods);
}

From source file:com.facebook.SharedPreferencesTokenCache.java

private void deserializeKey(String key, Bundle bundle) throws JSONException {
    String jsonString = cache.getString(key, "{}");
    JSONObject json = new JSONObject(jsonString);

    String valueType = json.getString(JSON_VALUE_TYPE);

    if (valueType.equals(TYPE_BOOLEAN)) {
        bundle.putBoolean(key, json.getBoolean(JSON_VALUE));
    } else if (valueType.equals(TYPE_BOOLEAN_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        boolean[] array = new boolean[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getBoolean(i);
        }//  w  ww  .  jav  a 2s . com
        bundle.putBooleanArray(key, array);
    } else if (valueType.equals(TYPE_BYTE)) {
        bundle.putByte(key, (byte) json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_BYTE_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        byte[] array = new byte[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = (byte) jsonArray.getInt(i);
        }
        bundle.putByteArray(key, array);
    } else if (valueType.equals(TYPE_SHORT)) {
        bundle.putShort(key, (short) json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_SHORT_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        short[] array = new short[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = (short) jsonArray.getInt(i);
        }
        bundle.putShortArray(key, array);
    } else if (valueType.equals(TYPE_INTEGER)) {
        bundle.putInt(key, json.getInt(JSON_VALUE));
    } else if (valueType.equals(TYPE_INTEGER_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        int[] array = new int[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getInt(i);
        }
        bundle.putIntArray(key, array);
    } else if (valueType.equals(TYPE_LONG)) {
        bundle.putLong(key, json.getLong(JSON_VALUE));
    } else if (valueType.equals(TYPE_LONG_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        long[] array = new long[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getLong(i);
        }
        bundle.putLongArray(key, array);
    } else if (valueType.equals(TYPE_FLOAT)) {
        bundle.putFloat(key, (float) json.getDouble(JSON_VALUE));
    } else if (valueType.equals(TYPE_FLOAT_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        float[] array = new float[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = (float) jsonArray.getDouble(i);
        }
        bundle.putFloatArray(key, array);
    } else if (valueType.equals(TYPE_DOUBLE)) {
        bundle.putDouble(key, json.getDouble(JSON_VALUE));
    } else if (valueType.equals(TYPE_DOUBLE_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        double[] array = new double[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            array[i] = jsonArray.getDouble(i);
        }
        bundle.putDoubleArray(key, array);
    } else if (valueType.equals(TYPE_CHAR)) {
        String charString = json.getString(JSON_VALUE);
        if (charString != null && charString.length() == 1) {
            bundle.putChar(key, charString.charAt(0));
        }
    } else if (valueType.equals(TYPE_CHAR_ARRAY)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        char[] array = new char[jsonArray.length()];
        for (int i = 0; i < array.length; i++) {
            String charString = jsonArray.getString(i);
            if (charString != null && charString.length() == 1) {
                array[i] = charString.charAt(0);
            }
        }
        bundle.putCharArray(key, array);
    } else if (valueType.equals(TYPE_STRING)) {
        bundle.putString(key, json.getString(JSON_VALUE));
    } else if (valueType.equals(TYPE_STRING_LIST)) {
        JSONArray jsonArray = json.getJSONArray(JSON_VALUE);
        int numStrings = jsonArray.length();
        ArrayList<String> stringList = new ArrayList<String>(numStrings);
        for (int i = 0; i < numStrings; i++) {
            Object jsonStringValue = jsonArray.get(i);
            stringList.add(i, jsonStringValue == JSONObject.NULL ? null : (String) jsonStringValue);
        }
        bundle.putStringArrayList(key, stringList);
    }
}

From source file:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java

/**
 * ????????./*from  ww w.ja  va2s.c o  m*/
 * 
 * @param sensorEvent .
 */
public void onSensorChanged(final SensorEvent sensorEvent) {
    if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

        mAccellX = sensorEvent.values[0];
        mAccellY = sensorEvent.values[1];
        mAccellZ = sensorEvent.values[2];

        Bundle orientation = new Bundle();
        Bundle a1 = new Bundle();
        a1.putDouble(DeviceOrientationProfile.PARAM_X, 0.0);
        a1.putDouble(DeviceOrientationProfile.PARAM_Y, 0.0);
        a1.putDouble(DeviceOrientationProfile.PARAM_Z, 0.0);
        Bundle a2 = new Bundle();
        a2.putDouble(DeviceOrientationProfile.PARAM_X, mAccellX);
        a2.putDouble(DeviceOrientationProfile.PARAM_Y, mAccellY);
        a2.putDouble(DeviceOrientationProfile.PARAM_Z, mAccellZ);
        Bundle r = new Bundle();
        r.putDouble(DeviceOrientationProfile.PARAM_ALPHA, mGyroX);
        r.putDouble(DeviceOrientationProfile.PARAM_BETA, mGyroY);
        r.putDouble(DeviceOrientationProfile.PARAM_GAMMA, mGyroZ);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION, a1);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION_INCLUDING_GRAVITY, a2);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ROTATION_RATE, r);
        orientation.putLong(DeviceOrientationProfile.PARAM_INTERVAL, 0);
        DeviceOrientationProfile.setInterval(orientation, INTERVAL_TIME);

        List<Event> events = EventManager.INSTANCE.getEventList(mDeviceId,
                DeviceOrientationProfile.PROFILE_NAME, null,
                DeviceOrientationProfile.ATTRIBUTE_ON_DEVICE_ORIENTATION);

        for (int i = 0; i < events.size(); i++) {
            Event event = events.get(i);
            Intent intent = EventManager.createEventMessage(event);

            intent.putExtra(DeviceOrientationProfile.PARAM_ORIENTATION, orientation);
            getContext().sendBroadcast(intent);
        }

    } else if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
        mGyroX = sensorEvent.values[0];
        mGyroY = sensorEvent.values[1];
        mGyroZ = sensorEvent.values[2];
    }
}