Example usage for android.os Bundle putLongArray

List of usage examples for android.os Bundle putLongArray

Introduction

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

Prototype

public void putLongArray(@Nullable String key, @Nullable long[] value) 

Source Link

Document

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

Usage

From source file:com.android.music.AlbumBrowserActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    badSymptoms.saveMenu("popup", item.toString());

    switch (item.getItemId()) {
    case PLAY_SELECTION: {
        // play the selected album
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        MusicUtils.playAll(this, list, 0);
        return true;
    }/*from  www.  j  a v a  2  s  . com*/

    case QUEUE: {
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        MusicUtils.addToCurrentPlaylist(this, list);
        return true;
    }

    case NEW_PLAYLIST: {
        Intent intent = new Intent();
        intent.setClass(this, CreatePlaylist.class);
        startActivityForResult(intent, NEW_PLAYLIST);
        return true;
    }

    case PLAYLIST_SELECTED: {
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        long playlist = item.getIntent().getLongExtra("playlist", 0);
        MusicUtils.addToPlaylist(this, list, playlist);
        return true;
    }
    case DELETE_ITEM: {
        long[] list = MusicUtils.getSongListForAlbum(this, Long.parseLong(mCurrentAlbumId));
        String f;
        if (android.os.Environment.isExternalStorageRemovable()) {
            f = getString(R.string.delete_album_desc);
        } else {
            f = getString(R.string.delete_album_desc_nosdcard);
        }
        String desc = String.format(f, mCurrentAlbumName);
        Bundle b = new Bundle();
        b.putString("description", desc);
        b.putLongArray("items", list);
        Intent intent = new Intent();
        intent.setClass(this, DeleteItems.class);
        intent.putExtras(b);
        startActivityForResult(intent, -1);
        return true;
    }
    case SEARCH:
        doSearch();
        return true;

    }
    return super.onContextItemSelected(item);
}

From source file:org.tigase.mobile.roster.RosterFragment.java

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

    this.expandedIds = getExpandedIds();
    if (DEBUG)//from w w  w.  j  a  v a 2s .  c o m
        Log.d(TAG, "Save roster view state." + (this.expandedIds != null));
    outState.putLongArray("ExpandedIds", this.expandedIds);
}

From source file:com.github.gorbin.asne.twitter.TwitterSocialNetwork.java

/**
 * Request ArrayList of {@link com.github.gorbin.asne.core.persons.SocialPerson} by array of userIds
 * @param userID array of user ids in social network
 * @param onRequestSocialPersonsCompleteListener listener for request ArrayList of {@link com.github.gorbin.asne.core.persons.SocialPerson}
 *//*from www. j a v  a2 s .c o m*/
@Override
public void requestSocialPersons(String[] userID,
        OnRequestSocialPersonsCompleteListener onRequestSocialPersonsCompleteListener) {
    super.requestSocialPersons(userID, onRequestSocialPersonsCompleteListener);
    ArrayList<String> users = new ArrayList<String>(Arrays.asList(userID));
    int i = 0;
    long[] usersId = new long[users.size()];
    for (String user : users) {
        if (TextUtils.isEmpty(user)) {
            users.remove(user);
            break;
        }
        try {
            usersId[i] = Long.parseLong(user);
        } catch (NumberFormatException e) {
            throw new SocialNetworkException("userID should be long number");
        }
        i++;
    }

    Bundle args = new Bundle();
    args.putLongArray(RequestSocialPersonsAsyncTask.PARAM_USER_ID, usersId);
    executeRequest(new RequestSocialPersonsAsyncTask(), args, REQUEST_GET_PERSON);
}

From source file:org.sufficientlysecure.keychain.ui.EncryptMessageFragment.java

private void encryptStart(final boolean toClipboard) {
    // Send all information needed to service to edit key in other thread
    Intent intent = new Intent(getActivity(), KeychainIntentService.class);

    intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN);

    // fill values for this action
    Bundle data = new Bundle();

    data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);

    String message = mMessage.getText().toString();

    if (mEncryptInterface.isModeSymmetric()) {
        Log.d(Constants.TAG, "Symmetric encryption enabled!");
        String passphrase = mEncryptInterface.getPassphrase();
        if (passphrase.length() == 0) {
            passphrase = null;//w ww .j av a2s. co m
        }
        data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
    } else {
        data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
        data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
                mEncryptInterface.getEncryptionKeys());

        boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
                || mEncryptInterface.getEncryptionKeys().length == 0);
        if (signOnly) {
            message = fixBadCharactersForGmail(message);
        }
    }

    data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());

    data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, true);

    int compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression();
    data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId);

    intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

    // Message is received after encrypting is done in KeychainIntentService
    KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(),
            getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard KeychainIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                // get returned data bundle
                Bundle data = message.getData();

                String output = new String(data.getByteArray(KeychainIntentService.RESULT_BYTES));
                Log.d(Constants.TAG, "output: " + output);

                if (toClipboard) {
                    ClipboardReflection.copyToClipboard(getActivity(), output);
                    AppMsg.makeText(getActivity(), R.string.encrypt_sign_clipboard_successful,
                            AppMsg.STYLE_INFO).show();
                } else {
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);

                    // Type is set to text/plain so that encrypted messages can
                    // be sent with Whatsapp, Hangouts, SMS etc...
                    sendIntent.setType("text/plain");

                    sendIntent.putExtra(Intent.EXTRA_TEXT, output);
                    startActivity(Intent.createChooser(sendIntent, getString(R.string.title_share_with)));
                }
            }
        }
    };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(saveHandler);
    intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);

    // show progress dialog
    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);
}

From source file:org.thialfihar.android.apg.ui.EncryptMessageFragment.java

private void encryptStart(final boolean toClipboard) {
    // Send all information needed to service to edit key in other thread
    Intent intent = new Intent(getActivity(), ApgIntentService.class);

    intent.setAction(ApgIntentService.ACTION_ENCRYPT_SIGN);

    // fill values for this action
    Bundle data = new Bundle();

    data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);

    String message = mMessage.getText().toString();

    if (mEncryptInterface.isModeSymmetric()) {
        Log.d(Constants.TAG, "Symmetric encryption enabled!");
        String passphrase = mEncryptInterface.getPassphrase();
        if (passphrase.length() == 0) {
            passphrase = null;//from  w  w w  . ja va 2s.  c o m
        }
        data.putString(ApgIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
    } else {
        data.putLong(ApgIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
        data.putLongArray(ApgIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());

        boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null
                || mEncryptInterface.getEncryptionKeys().length == 0);
        if (signOnly) {
            message = fixBadCharactersForGmail(message);
        }
    }

    data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());

    data.putBoolean(ApgIntentService.ENCRYPT_USE_ASCII_ARMOR, true);

    int compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression();
    data.putInt(ApgIntentService.ENCRYPT_COMPRESSION_ID, compressionId);

    intent.putExtra(ApgIntentService.EXTRA_DATA, data);

    final Activity activity = getActivity();
    // Message is received after encrypting is done in ApgIntentService
    ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(getActivity(),
            getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard ApgIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                // get returned data bundle
                Bundle data = message.getData();

                String output = new String(data.getByteArray(ApgIntentService.RESULT_BYTES));
                Log.d(Constants.TAG, "output: " + output);

                if (mLegacyMode) {
                    Intent result = new Intent();
                    result.putExtra("encryptedMessage", output);
                    activity.setResult(activity.RESULT_OK, result);
                    activity.finish();
                    return;
                } else if (toClipboard) {
                    ClipboardReflection.copyToClipboard(getActivity(), output);
                    AppMsg.makeText(getActivity(), R.string.encrypt_sign_clipboard_successful,
                            AppMsg.STYLE_INFO).show();
                } else {
                    Intent sendIntent = new Intent(Intent.ACTION_SEND);

                    // Type is set to text/plain so that encrypted messages can
                    // be sent with Whatsapp, Hangouts, SMS etc...
                    sendIntent.setType("text/plain");

                    sendIntent.putExtra(Intent.EXTRA_TEXT, output);
                    startActivity(Intent.createChooser(sendIntent, getString(R.string.title_share_with)));
                }
            }
        }
    };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(saveHandler);
    intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);

    // show progress dialog
    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);
}

From source file:org.thialfihar.android.apg.ui.EncryptFileFragment.java

private void encryptStart() {
    // Send all information needed to service to edit key in other thread
    Intent intent = new Intent(getActivity(), ApgIntentService.class);

    intent.setAction(ApgIntentService.ACTION_ENCRYPT_SIGN);

    // fill values for this action
    Bundle data = new Bundle();

    data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_URI);

    if (mEncryptInterface.isModeSymmetric()) {
        Log.d(Constants.TAG, "Symmetric encryption enabled!");
        String passphrase = mEncryptInterface.getPassphrase();
        if (passphrase.length() == 0) {
            passphrase = null;//from  ww w. jav a2 s. c o m
        }
        data.putString(ApgIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
    } else {
        data.putLong(ApgIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
        data.putLongArray(ApgIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys());
    }

    Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" + mOutputFilename);

    data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
    data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);

    boolean useAsciiArmor = mAsciiArmor.isChecked();
    data.putBoolean(ApgIntentService.ENCRYPT_USE_ASCII_ARMOR, useAsciiArmor);

    int compressionId = ((Choice) mFileCompression.getSelectedItem()).getId();
    data.putInt(ApgIntentService.ENCRYPT_COMPRESSION_ID, compressionId);

    intent.putExtra(ApgIntentService.EXTRA_DATA, data);

    // Message is received after encrypting is done in ApgIntentService
    ApgIntentServiceHandler saveHandler = new ApgIntentServiceHandler(getActivity(),
            getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard ApgIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
                AppMsg.makeText(getActivity(), R.string.encrypt_sign_successful, AppMsg.STYLE_INFO).show();

                if (mDeleteAfter.isChecked()) {
                    // Create and show dialog to delete original file
                    DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
                            .newInstance(mInputFilename);
                    deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog");
                }

                if (mShareAfter.isChecked()) {
                    // Share encrypted file
                    Intent sendFileIntent = new Intent(Intent.ACTION_SEND);
                    sendFileIntent.setType("*/*");
                    sendFileIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(mOutputFilename));
                    startActivity(Intent.createChooser(sendFileIntent, getString(R.string.title_share_file)));
                }
            }
        }
    };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(saveHandler);
    intent.putExtra(ApgIntentService.EXTRA_MESSENGER, messenger);

    // show progress dialog
    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);
}

From source file:org.sufficientlysecure.keychain.ui.EncryptFileFragment.java

private void encryptStart() {
    // Send all information needed to service to edit key in other thread
    Intent intent = new Intent(getActivity(), KeychainIntentService.class);

    intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN);

    // fill values for this action
    Bundle data = new Bundle();

    data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI);

    if (mEncryptInterface.isModeSymmetric()) {
        Log.d(Constants.TAG, "Symmetric encryption enabled!");
        String passphrase = mEncryptInterface.getPassphrase();
        if (passphrase.length() == 0) {
            passphrase = null;/*from   w ww . j a v  a 2 s  .  c  om*/
        }
        data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase);
    } else {
        data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey());
        data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS,
                mEncryptInterface.getEncryptionKeys());
    }

    Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" + mOutputFilename);

    data.putString(KeychainIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
    data.putString(KeychainIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);

    boolean useAsciiArmor = mAsciiArmor.isChecked();
    data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, useAsciiArmor);

    int compressionId = ((Choice) mFileCompression.getSelectedItem()).getId();
    data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId);

    intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

    // Message is received after encrypting is done in KeychainIntentService
    KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(),
            getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) {
        public void handleMessage(Message message) {
            // handle messages by standard KeychainIntentServiceHandler first
            super.handleMessage(message);

            if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                AppMsg.makeText(getActivity(), R.string.encrypt_sign_successful, AppMsg.STYLE_INFO).show();

                if (mDeleteAfter.isChecked()) {
                    // Create and show dialog to delete original file
                    DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
                            .newInstance(mInputFilename);
                    deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog");
                }

                if (mShareAfter.isChecked()) {
                    // Share encrypted file
                    Intent sendFileIntent = new Intent(Intent.ACTION_SEND);
                    sendFileIntent.setType("*/*");
                    sendFileIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(mOutputFilename));
                    startActivity(Intent.createChooser(sendFileIntent, getString(R.string.title_share_file)));
                }
            }
        }
    };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(saveHandler);
    intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);

    // show progress dialog
    saveHandler.showProgressDialog(getActivity());

    // start service with intent
    getActivity().startService(intent);
}

From source file:org.lyricue.android.Lyricue.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    for (String key : fragments.keySet()) {
        if (getSupportFragmentManager() != null) {
            if (fragments.get(key) != null) {
                getSupportFragmentManager().putFragment(outState, key, fragments.get(key));
            }//  w  ww .  jav a  2 s. c om
        }
    }
    outState.putParcelableArray("hosts", hosts);
    outState.putString("profile", profile);
    outState.putLong("playlistid", playlistid);
    outState.putStringArray("playlists_text", playlists_text);
    outState.putLongArray("playlists_id", playlists_id);
    outState.putStringArray("bibles_text", bibles_text);
    outState.putStringArray("bibles_id", bibles_id);
    outState.putStringArray("bibles_type", bibles_type);
    super.onSaveInstanceState(outState);
}

From source file:org.mariotaku.twidere.activity.ComposeActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case MENU_HOME: {
        final String text = mEditText != null ? parseString(mEditText.getText()) : null;
        if (mContentModified && !isEmpty(text)) {
            mUnsavedTweetDialogFragment = (DialogFragment) Fragment.instantiate(this,
                    UnsavedTweetDialogFragment.class.getName());
            final Bundle args = new Bundle();
            args.putBoolean(INTENT_KEY_IS_NAVIGATE_UP, true);
            mUnsavedTweetDialogFragment.setArguments(args);
            mUnsavedTweetDialogFragment.show(getSupportFragmentManager(), "unsaved_tweet");
        } else {/*from w  w  w . j a  va 2 s  .c o  m*/
            // NavUtils.navigateUpFromSameTask(this);
            onBackPressed();
        }
        break;
    }
    case MENU_SEND: {
        send();
        break;
    }
    case MENU_SELECT_ACCOUNT: {
        final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT);
        final Bundle bundle = new Bundle();
        bundle.putBoolean(INTENT_KEY_ACTIVATED_ONLY, false);
        bundle.putLongArray(INTENT_KEY_IDS, mAccountIds);
        intent.putExtras(bundle);
        startActivityForResult(intent, REQUEST_SELECT_ACCOUNT);
        break;
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.czlee.debatekeeper.debatemanager.DebateManager.java

/**
 * Saves the state of this <code>DebateManager</code> to a {@link Bundle}.
 * @param key A String to uniquely distinguish this <code>DebateManager</code> from any other
 *        objects that might be stored in the same Bundle.
 * @param bundle The Bundle to which to save this information.
 *//* w  ww  .  jav a 2s  .  c  o m*/
public void saveState(String key, Bundle bundle) {

    // Take note of which item type we're in
    bundle.putString(key + BUNDLE_SUFFIX_ITEM_TYPE, mActivePhaseType.toString());

    // Take note of which speech we're on
    bundle.putInt(key + BUNDLE_SUFFIX_INDEX, mActiveSpeechIndex);

    // Save the speech times
    long[] speechTimes = new long[mSpeechTimes.size()];
    for (int i = 0; i < mSpeechTimes.size(); i++)
        speechTimes[i] = mSpeechTimes.get(i);
    bundle.putLongArray(key + BUNDLE_SUFFIX_SPEECH_TIMES, speechTimes);

    // Save the prep time
    bundle.putLong(key + BUNDLE_SUFFIX_PREP_TIME, mPrepTime);

    mPhaseManager.saveState(key + BUNDLE_SUFFIX_SPEECH, bundle);
}