List of usage examples for android.os Bundle putByteArray
@Override public void putByteArray(@Nullable String key, @Nullable byte[] value)
From source file:org.hopestarter.wallet.ui.RequestCoinsFragment.java
private void saveInstanceState(final Bundle outState) { outState.putByteArray("receive_address", address.getHash160()); }
From source file:com.frostwire.android.gui.dialogs.HandpickedTorrentDownloadDialog.java
@Override public void onSaveInstanceState(Bundle outState) { if (outState != null && torrentInfo != null) { outState.putByteArray(BUNDLE_KEY_TORRENT_INFO_DATA, torrentInfo.bencode()); outState.putString(BUNDLE_KEY_MAGNET_URI, magnetUri); outState.putLong(BUNDLE_KEY_TORRENT_FETCHER_DOWNLOAD_TOKEN_ID, torrentFetcherDownloadTokenId); }/* w w w . j a v a2s . co m*/ super.onSaveInstanceState(outState); //saves the torrentInfo in bytes. }
From source file:com.nonstop.android.SoC.Facebook.Hackbook.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { /*//from w w w. j av a2 s . c o m * if this is the activity result from authorization flow, do a call * back to authorizeCallback Source Tag: login_tag */ case AUTHORIZE_ACTIVITY_RESULT_CODE: { Utility.mFacebook.authorizeCallback(requestCode, resultCode, data); break; } /* * if this is the result for a photo picker from the gallery, upload * the image after scaling it. You can use the Utility.scaleImage() * function for scaling */ case PICK_EXISTING_PHOTO_RESULT_CODE: { if (resultCode == Activity.RESULT_OK) { Uri photoUri = data.getData(); if (photoUri != null) { Bundle params = new Bundle(); try { params.putByteArray("photo", Utility.scaleImage(getApplicationContext(), photoUri)); } catch (IOException e) { e.printStackTrace(); } params.putString("caption", "NonstopSoC"); Utility.mAsyncRunner.request("me/photos", params, "POST", new PhotoUploadListener(), null); } else { Toast.makeText(getApplicationContext(), "Error selecting image from the gallery.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "No image selected for upload.", Toast.LENGTH_SHORT).show(); } break; } } }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java
public void loadKeyListFragment() { if (mImportData != null || mImportFilename != null) { // generate list of keyrings FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ImportKeysListFragment listFragment = new ImportKeysListFragment(); Bundle args = new Bundle(); args.putByteArray(ImportKeysListFragment.ARG_KEYRING_BYTES, mImportData); args.putString(ImportKeysListFragment.ARG_IMPORT_FILENAME, mImportFilename); listFragment.setArguments(args); // replace container in view with fragment fragmentTransaction.replace(R.id.import_keys_list_container, listFragment); fragmentTransaction.commit();/*from www. j a va 2 s. c om*/ } }
From source file:me.xiaopan.android.inject.sample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); listView = new ListView(getBaseContext()); setContentView(listView);//from ww w . jav a 2 s .c o m // SharedPreferences? PreferenceUtils.putBoolean(getBaseContext(), KEY_BOOLEAN, true); PreferenceUtils.putFloat(getBaseContext(), KEY_FLOAT, 10000f); PreferenceUtils.putInt(getBaseContext(), KEY_INT, 2000); PreferenceUtils.putLong(getBaseContext(), KEY_LONG, 50000); PreferenceUtils.putString(getBaseContext(), KEY_STRING, "Preference String"); Set<String> stringSet = new HashSet<String>(); stringSet.add("String Set 1"); stringSet.add("String Set 2"); stringSet.add("String Set 3"); stringSet.add("String Set 4"); PreferenceUtils.putStringSet(getBaseContext(), KEY_STRING_SET, stringSet); MyBean bean2 = new MyBean(); bean2.setEmail("sky@xiaopan.me2"); bean2.setName("?2"); bean2.setSex("2"); PreferenceUtils.putObject(getBaseContext(), KEY_JSON, bean2); PreferenceUtils.putString(getBaseContext(), KEY_ENUM, Sex.WOMAN.name()); // ?? String[] items = new String[] { "", "?", "FragmentDialog", "InjectAdapter", "InjectExpandableListAdapter" }; listView.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1, android.R.id.text1, items)); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (position <= 2) { Bundle bundle = new Bundle(); bundle.putBoolean(MainActivity.PARAM_BOOLEAN, true); bundle.putBooleanArray(MainActivity.PARAM_BOOLEAN_ARRAY, new boolean[] { true, false, true }); bundle.putByte(MainActivity.PARAM_BYTE, (byte) 110); bundle.putByteArray(MainActivity.PARAM_BYTE_ARRAY, new byte[] { 111, 112, 113 }); bundle.putChar(MainActivity.PARAM_CHAR, 'R'); bundle.putCharArray(MainActivity.PARAM_CHAR_ARRAY, new char[] { 'c', 'h', 'a', 'r' }); bundle.putCharSequence(MainActivity.PARAM_CHAR_SEQUENCE, "CharSequence"); bundle.putCharSequenceArray(MainActivity.PARAM_CHAR_SEQUENCE_ARRAY, new CharSequence[] { "Char", " ", "Sequence" }); bundle.putDouble(MainActivity.PARAM_DOUBLE, 12.00d); bundle.putDoubleArray(MainActivity.PARAM_DOUBLE_ARRAY, new double[] { 12.01d, 12.02d, 12.03d }); bundle.putFloat(MainActivity.PARAM_FLOAT, 13.00f); bundle.putFloatArray(MainActivity.PARAM_FLOAT_ARRAY, new float[] { 13.01f, 13.02f, 13.03f }); bundle.putInt(MainActivity.PARAM_INT, 120); bundle.putIntArray(MainActivity.PARAM_INT_ARRAY, new int[] { 121, 122, 123, }); bundle.putLong(MainActivity.PARAM_LONG, 12345); bundle.putLongArray(MainActivity.PARAM_LONG_ARRAY, new long[] { 12346, 12347, 12348 }); bundle.putShort(MainActivity.PARAM_SHORT, (short) 2); bundle.putShortArray(MainActivity.PARAM_SHORT_ARRAY, new short[] { 3, 4, 5 }); bundle.putString(MainActivity.PARAM_STRING, "String"); bundle.putStringArray(MainActivity.PARAM_STRING_ARRAY, new String[] { "String1", "String2", "String3" }); // ??JSONBundle MyBean bean = new MyBean(); bean.setEmail("sky@xiaopan.me"); bean.setName("?"); bean.setSex(""); bundle.putString(PARAM_STRING_JSON, new Gson().toJson(bean)); bundle.putString(MainActivity.PARAM_STRING_ENUM, Sex.WOMAN.name()); // ArrayList<String> stringList = new ArrayList<String>(); stringList.add("ArrayList String 1"); stringList.add("ArrayList String 2"); stringList.add("ArrayList String 3"); bundle.putStringArrayList(MainActivity.PARAM_STRING_ARRAY_LIST, stringList); switch (position) { case 0: Second.SECOND_CHRONOGRAPH.lap(); Intent intent = new Intent(getBaseContext(), InjectTestActivity.class); intent.putExtras(bundle); startActivity(intent); break; case 1: Second.SECOND_CHRONOGRAPH.lap(); Intent intent2 = new Intent(getBaseContext(), NormalActivity.class); intent2.putExtras(bundle); startActivity(intent2); break; case 2: Second.SECOND_CHRONOGRAPH.lap(); new TestDialogFragment().show(getSupportFragmentManager(), ""); break; } } else { Class<?> targetClass = null; if (position == 3) { targetClass = InjectAdapterActivity.class; } else if (position == 4) { targetClass = InjectExpandableListAdapterActivity.class; } if (targetClass != null) { startActivity(new Intent(getBaseContext(), targetClass)); } } } }); }
From source file:com.evandroid.musica.MainLyricActivity.java
public void updateLyricsFragment(int outAnim, int inAnim, boolean transition, Lyrics lyrics) { LyricsViewFragment lyricsViewFragment = (LyricsViewFragment) getFragmentManager() .findFragmentByTag(LYRICS_FRAGMENT_TAG); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(inAnim, outAnim, inAnim, outAnim); Fragment activeFragment = getDisplayedFragment(getActiveFragments()); if (lyricsViewFragment != null && lyricsViewFragment.getView() != null) { SharedPreferences preferences = getSharedPreferences("current_music", Context.MODE_PRIVATE); String artist = preferences.getString("artist", null); String track = preferences.getString("track", null); if (lyrics.isLRC() && !(lyrics.getOriginalArtist().equals(artist) && lyrics.getOriginalTrack().equals(track))) { LrcView parser = new LrcView(this, null); parser.setOriginalLyrics(lyrics); parser.setSourceLrc(lyrics.getText()); lyrics = parser.getStaticLyrics(); }/*from w w w . j a v a 2s . c o m*/ lyricsViewFragment.update(lyrics, lyricsViewFragment.getView(), true); if (transition) { fragmentTransaction.hide(activeFragment).show(lyricsViewFragment); prepareAnimations(activeFragment); prepareAnimations(lyricsViewFragment); } } else { Bundle lyricsBundle = new Bundle(); try { lyricsBundle.putByteArray("lyrics", lyrics.toBytes()); } catch (IOException e) { e.printStackTrace(); } lyricsViewFragment = new LyricsViewFragment(); lyricsViewFragment.setArguments(lyricsBundle); if (!(activeFragment instanceof LyricsViewFragment) && activeFragment != null) fragmentTransaction.hide(activeFragment).add(R.id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); else fragmentTransaction.replace(R.id.main_fragment_container, lyricsViewFragment, LYRICS_FRAGMENT_TAG); } fragmentTransaction.commitAllowingStateLoss(); }
From source file:github.popeen.dsub.service.AutoMediaBrowserService.java
private void getBookmarks(final Result<List<MediaBrowserCompat.MediaItem>> result) { new SilentServiceTask<MusicDirectory>(downloadService) { @Override/*from ww w.ja va 2s .c o m*/ protected MusicDirectory doInBackground(MusicService musicService) throws Throwable { return musicService.getBookmarks(false, downloadService, null); } @Override protected void done(MusicDirectory bookmarkList) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); for (Entry entry : bookmarkList.getChildren(false, true)) { try { Bundle extras = new Bundle(); extras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, entry.toByteArray()); extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId()); MediaDescriptionCompat description = new MediaDescriptionCompat.Builder() .setTitle(entry.getTitle()) .setSubtitle(Util.formatDuration(entry.getBookmark().getPosition() / 1000)) .setMediaId(entry.getId()).setExtras(extras).build(); mediaItems.add(new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)); } catch (IOException e) { Log.e(TAG, "Failed to add entry", e); } } result.sendResult(mediaItems); } }.execute(); result.detach(); }
From source file:github.popeen.dsub.service.AutoMediaBrowserService.java
private void getPodcastEpisodes(final Result<List<MediaBrowserCompat.MediaItem>> result, final String podcastId) { new SilentServiceTask<MusicDirectory>(downloadService) { @Override//from w ww.ja v a 2 s. co m protected MusicDirectory doInBackground(MusicService musicService) throws Throwable { return musicService.getPodcastEpisodes(false, podcastId, downloadService, null); } @Override protected void done(MusicDirectory podcasts) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); for (Entry entry : podcasts.getChildren(false, true)) { try { PodcastEpisode podcast = (PodcastEpisode) entry; Bundle podcastExtras = new Bundle(); podcastExtras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, podcast.toByteArray()); podcastExtras.putString(Constants.INTENT_EXTRA_NAME_PODCAST_ID, podcast.getId()); MediaDescriptionCompat description = new MediaDescriptionCompat.Builder() .setTitle(podcast.getTitle()) .setSubtitle(Util.formatDate(downloadService, podcast.getDate(), false)) .setMediaId(PODCAST_PREFIX + podcast.getId()).setExtras(podcastExtras).build(); mediaItems.add(new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)); } catch (IOException e) { Log.e(TAG, "Failed to add podcast", e); } } result.sendResult(mediaItems); } }.execute(); result.detach(); }
From source file:github.popeen.dsub.service.AutoMediaBrowserService.java
private void getIndexes(final Result<List<MediaBrowserCompat.MediaItem>> result, final String musicFolderId) { new SilentServiceTask<Indexes>(downloadService) { @Override//from w ww. j a va 2s . c o m protected Indexes doInBackground(MusicService musicService) throws Throwable { return musicService.getIndexes(musicFolderId, false, downloadService, null); } @Override protected void done(Indexes indexes) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); // music directories for (Artist artist : indexes.getArtists()) { MediaDescriptionCompat description = new MediaDescriptionCompat.Builder() .setTitle(artist.getName()).setMediaId(MUSIC_DIRECTORY_CONTENTS_PREFIX + artist.getId()) .build(); mediaItems.add(new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)); } // music files for (Entry entry : indexes.getEntries()) { try { entry.setBookmark(null); // don't resume from a bookmark in a browse listing Bundle extras = new Bundle(); extras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, entry.toByteArray()); extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId()); MediaDescriptionCompat description = new MediaDescriptionCompat.Builder() .setTitle(entry.getTitle()).setMediaId(entry.getId()).setExtras(extras).build(); mediaItems.add(new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)); } catch (IOException e) { Log.e(TAG, "Failed to add entry", e); } } result.sendResult(mediaItems); } }.execute(); result.detach(); }
From source file:github.popeen.dsub.service.AutoMediaBrowserService.java
private void getMusicDirectory(final Result<List<MediaBrowserCompat.MediaItem>> result, final String musicDirectoryId) { new SilentServiceTask<MusicDirectory>(downloadService) { @Override//from www . j a va2 s .com protected MusicDirectory doInBackground(MusicService musicService) throws Throwable { return musicService.getMusicDirectory(musicDirectoryId, "", false, downloadService, null); } @Override protected void done(MusicDirectory directory) { List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>(); addPlayOptions(mediaItems, musicDirectoryId, Constants.INTENT_EXTRA_NAME_ID); for (Entry entry : directory.getChildren()) { MediaDescriptionCompat description; if (entry.isDirectory()) { // browse deeper description = new MediaDescriptionCompat.Builder().setTitle(entry.getTitle()) .setMediaId(MUSIC_DIRECTORY_CONTENTS_PREFIX + entry.getId()).build(); mediaItems.add(new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_BROWSABLE)); } else { try { // mark individual songs as directly playable entry.setBookmark(null); // don't resume from a bookmark in a browse listing Bundle extras = new Bundle(); extras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, entry.toByteArray()); extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId()); description = new MediaDescriptionCompat.Builder().setTitle(entry.getTitle()) .setMediaId(entry.getId()).setExtras(extras).build(); mediaItems.add(new MediaBrowserCompat.MediaItem(description, MediaBrowserCompat.MediaItem.FLAG_PLAYABLE)); } catch (IOException e) { Log.e(TAG, "Failed to add entry", e); } } } result.sendResult(mediaItems); } }.execute(); result.detach(); }