public void onFullScan(int[] frequency, int[] signalStrength, boolean aborted) { Message msg = Message.obtain(); msg.what = TYPE_ON_FULLSCAN; Bundle b = new Bundle(); b.putIntArray("frequency", frequency); b.putIntArray("signalStrength", signalStrength); b.putBoolean("aborted", aborted); msg.obj = b; mListenerHandler.sendMessage(msg); }
/** * This method is called by SDL using JNI. Shows the messagebox from UI thread and block calling * thread. buttonFlags, buttonIds and buttonTexts must have same length. * * @param buttonFlags array containing flags for every button. * @param buttonIds array containing id for every button. * @param buttonTexts array containing text for every button. * @param colors null for default or array of length 5 containing colors. * @return button id or -1. */ public int messageboxShowMessageBox( final int flags, final String title, final String message, final int[] buttonFlags, final int[] buttonIds, final String[] buttonTexts, final int[] colors) { messageboxSelection[0] = -1; // sanity checks if ((buttonFlags.length != buttonIds.length) && (buttonIds.length != buttonTexts.length)) { return -1; // implementation broken } // collect arguments for Dialog final Bundle args = new Bundle(); args.putInt("flags", flags); args.putString("title", title); args.putString("message", message); args.putIntArray("buttonFlags", buttonFlags); args.putIntArray("buttonIds", buttonIds); args.putStringArray("buttonTexts", buttonTexts); args.putIntArray("colors", colors); // trigger Dialog creation on UI thread runOnUiThread( new Runnable() { @Override public void run() { showDialog(dialogs++, args); } }); // block the calling thread synchronized (messageboxSelection) { try { messageboxSelection.wait(); } catch (InterruptedException ex) { ex.printStackTrace(); return -1; } } // return selected value return messageboxSelection[0]; }
/** * Save game state so that the user does not lose anything if the game process is killed while we * are in the background. * * @return a Bundle with this view's state */ public Bundle saveState() { Bundle map = new Bundle(); map.putIntArray("mAppleList", coordArrayListToArray(mAppleList)); map.putInt("mDirection", Integer.valueOf(mDirection)); map.putInt("mNextDirection", Integer.valueOf(mNextDirection)); map.putLong("mMoveDelay", Long.valueOf(mMoveDelay)); map.putLong("mScore", Long.valueOf(mScore)); map.putIntArray("mSnakeTrail", coordArrayListToArray(mSnakeTrail)); return map; }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putIntArray(KEY_EXPANDED_IDS, mAdapter.getExpandedArray()); outState.putIntArray(KEY_REPEAT_CHECKED_IDS, mAdapter.getRepeatArray()); outState.putIntArray(KEY_SELECTED_ALARMS, mAdapter.getSelectedAlarmsArray()); outState.putBundle(KEY_RINGTONE_TITLE_CACHE, mRingtoneTitleCache); outState.putParcelable(KEY_DELETED_ALARM, mDeletedAlarm); outState.putBoolean(KEY_UNDO_SHOWING, mUndoShowing); outState.putBundle(KEY_PREVIOUS_DAY_MAP, mAdapter.getPreviousDaysOfWeekMap()); outState.putParcelable(KEY_SELECTED_ALARM, mSelectedAlarm); outState.putBoolean(KEY_DELETE_CONFIRMATION, mInDeleteConfirmation); }
/** * @param fragmentsToInt - integer representation of fragments 0 - ExploreFragment, 1 - * SearchResultFragment, 2 - RunsFragments 3 - LaunchHistoryFragments, 4 - MyWorkflowFragment, * 5 - FavouriteWorkflowFragment * @param backStackTag */ private void beginFragmentTransaction(int[] fragmentsToInt, String backStackTag) { FragmentManager fm = parentActivity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); // ft.setCustomAnimations(R.anim.push_left_in, R.anim.push_left_out); // boolean successfullypopped = fm.popBackStackImmediate(backStackTag, 1); // if(!successfullypopped){ Fragment newFragment = new FragmentsContainer(); Bundle args = new Bundle(); args.putIntArray("fragmentsToInstantiate", fragmentsToInt); newFragment.setArguments(args); ft.addToBackStack(backStackTag); if (previousSelectedFragTag == null) { fm.beginTransaction().hide(fm.findFragmentByTag("StarterFragments")).commit(); } else { fm.beginTransaction().hide(fm.findFragmentByTag(previousSelectedFragTag)).commit(); } previousSelectedFragTag = backStackTag; ft.replace(R.id.main_panel_root, newFragment, backStackTag).commit(); // } // smooth transaction new Handler() .postDelayed( new Runnable() { public void run() { // close the menu ((MainPanelActivity) parentActivity).getMenu().toggle(); } }, 500); }
@Override public boolean onBackPressed() { if (isTablet && !isPortrait) { return false; } else { Fragment currentFragment = getChildFragmentManager().findFragmentById(R.id.fragmentContainer); if (currentFragment instanceof ContentDetailFragment) { contentListFragment = new ContentListFragment(); Bundle bundle = new Bundle(); bundle.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames); bundle.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages); contentListFragment.setArguments(bundle); showPrimaryFragment(contentListFragment, false, null, true); isDetailShowing = false; // going back to main content new Handler() .postDelayed( new Runnable() { @Override public void run() { ((MainActivity) getActivity()).setUpNavOff(); } }, 250); return true; } else { return false; } } }
/** * Save the puzzle to a bundle * * @param bundle The bundle we save to */ public void saveInstanceState(Bundle bundle) { float[] locationX = new float[blocks.size() + 1]; float[] locationY = new float[blocks.size() + 1]; int[] weights = new int[blocks.size() + 1]; // store place blocks for (int i = 0; i < blocks.size(); i++) { Block piece = blocks.get(i); locationX[i] = piece.xPosition; locationY[i] = piece.yPosition; weights[i] = piece.weight; } // store temp block locationX[blocks.size()] = .5f; locationY[blocks.size()] = yPositionTracker; weights[blocks.size()] = tempBlock.weight; bundle.putFloatArray(LOCATIONX, locationX); bundle.putFloatArray(LOCATIONY, locationY); bundle.putIntArray(WEIGHT, weights); bundle.putInt(Turn, PlayerTurn); bundle.putInt(Score1, player1Score); bundle.putInt(Score2, player2Score); // remember who goes first if (blocks.size() % 2 == 0) bundle.putInt(First, PlayerTurn); else if (PlayerTurn == 1) bundle.putInt(First, 2); else bundle.putInt(First, 1); }
public static boolean putJSONValueInBundle(Bundle bundle, String key, Object value) { if (value == null) { bundle.remove(key); } else if (value instanceof Boolean) { bundle.putBoolean(key, ((Boolean) value).booleanValue()); } else if (value instanceof boolean[]) { bundle.putBooleanArray(key, (boolean[]) value); } else if (value instanceof Double) { bundle.putDouble(key, ((Double) value).doubleValue()); } else if (value instanceof double[]) { bundle.putDoubleArray(key, (double[]) value); } else if (value instanceof Integer) { bundle.putInt(key, ((Integer) value).intValue()); } else if (value instanceof int[]) { bundle.putIntArray(key, (int[]) value); } else if (value instanceof Long) { bundle.putLong(key, ((Long) value).longValue()); } else if (value instanceof long[]) { bundle.putLongArray(key, (long[]) value); } else if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof JSONArray) { bundle.putString(key, ((JSONArray) value).toString()); } else if (value instanceof JSONObject) { bundle.putString(key, ((JSONObject) value).toString()); } else { return false; } return true; }
/** * Add extended data to the extra. * * @param name The name of the extra data, with package prefix. * @param value The int array data value. * @return Returns the same extra object, for chaining multiple calls into a single statement. * @see #putExtras * @see #removeExtra * @see #getIntArrayExtra(String) */ public Request putExtra(String name, int[] value) { if (mExtras == null) { mExtras = new Bundle(); } mExtras.putIntArray(name, value); return this; }
public static void saveAnalysisData( ExperimentAnalysis.AnalysisEntry analysisEntry, IDataAnalysis sensorAnalysis, File storageDir, List<ISensorData> allSensorData) throws IOException { Bundle bundle = new Bundle(); // save plugin bundle.putString(PLUGIN_ID_KEY, analysisEntry.plugin.getIdentifier()); bundle.putString(ANALYSIS_UID_KEY, analysisEntry.analysisUid); // save used data ISensorData[] dataList = sensorAnalysis.getData(); int integerList[] = new int[dataList.length]; for (int i = 0; i < integerList.length; i++) integerList[i] = allSensorData.indexOf(dataList[i]); bundle.putIntArray(SENSOR_DATA_LIST_KEY, integerList); // save experiment data Bundle experimentData = sensorAnalysis.exportAnalysisData(storageDir); bundle.putBundle(USED_DATA_KEY, experimentData); // save the bundle File projectFile = new File(storageDir, IDataAnalysis.EXPERIMENT_ANALYSIS_FILE_NAME); FileWriter fileWriter = new FileWriter(projectFile); PersistentBundle persistentBundle = new PersistentBundle(); persistentBundle.flattenBundle(bundle, fileWriter); }
public static SelectFragment newInstance(int[] location) { SelectFragment fg = new SelectFragment(); Bundle bundle = new Bundle(); bundle.putIntArray("LOCATION", location); fg.setArguments(bundle); return fg; }
@Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a DummySectionFragment (defined as a static inner class // below) with the page number as its lone argument. String menu = getArguments().getString("Menu"); String username = getArguments().getString("User"); String pass = getArguments().getString("Pass"); String cokie = getArguments().getString("Cook"); String sub_name[] = getArguments().getStringArray("Array"); String day[] = getArguments().getStringArray("Array1"); int rpc[] = getArguments().getIntArray("Array2"); String cl_time[] = getArguments().getStringArray("Array3"); String sub_fac[] = getArguments().getStringArray("Array4"); String block[] = getArguments().getStringArray("Array5"); Fragment fragment = new DummySectionFragment(); Bundle args = new Bundle(); args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1); args.putString("Menu", "He"); args.putString("User", username); args.putString("Pass", pass); args.putString("Cook", cokie); args.putString("POSS", position + ""); args.putStringArray("Array", sub_name); args.putStringArray("Array1", day); args.putIntArray("Array2", rpc); args.putStringArray("Array3", cl_time); args.putStringArray("Array4", sub_fac); args.putStringArray("Array5", block); fragment.setArguments(args); return fragment; }
private void saveFragmentsStack(Bundle outState) { int[] stack = new int[fragmentsStack.size()]; for (int i = 0; i < stack.length; i++) { stack[i] = fragmentsStack.get(i); } outState.putIntArray(FRAGMENTS_STACK_KEY, stack); }
private void addPhoneViews() { contentListFragment = new ContentListFragment(); Bundle bundle = new Bundle(); bundle.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames); bundle.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages); contentListFragment.setArguments(bundle); showPrimaryFragment(contentListFragment, false, null, false); }
private static void putIntArray(String key, Bundle bundle) { int length = random.nextInt(50); int[] array = new int[length]; for (int i = 0; i < length; i++) { array[i] = random.nextInt(); } bundle.putIntArray(key, array); }
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(IS_DETAIL_SHOWING, isDetailShowing); outState.putInt(DETAIL_ITEM_POSITION, detailItemPosition); outState.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames); outState.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages); }
// Step 9.1:保存状态 @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(KEY_INDEX, mCurrentIndex); outState.putIntArray("cheatArray", CheatArray); // 练习5.2用于保存mIsCheating不被擦掉 outState.putBoolean(CheatActivity.KEY_CHEATED, mIsCheating); }
@Override protected void setInternalArguments(Bundle args) { super.setInternalArguments(args); args.putParcelable(DBDEFINITION, tbd); args.putInt(LAYOUT, layout); args.putInt(VIEWHOLDERLAYOUT, listLayout); args.putIntArray(VIEWRESIDS, viewResId); args.putIntArray(FROMRESIDS, fromResId); args.putString(SELECTION, selection); args.putStringArray(SELECTIONARGS, selectionArgs); }
@Override public void pushIntArray(int deviceID, int sensor, int[] data, int length, long timestamp) throws RemoteException { Bundle bundle = new Bundle(); bundle.putInt(BUNDLE_DEVICE_ID, deviceID); bundle.putInt(BUNDLE_SENSOR, sensor); bundle.putString(BUNDLE_TYPE, "int[]"); bundle.putIntArray(BUNDLE_DATA, data); bundle.putInt(BUNDLE_LENGTH, length); bundle.putLong(BUNDLE_TIMESTAMP, timestamp); mHandler.sendMessage(mHandler.obtainMessage(MSG_PUSH_DATA, bundle)); }
@Override protected void setInternalArguments(Bundle args) { super.setInternalArguments(args); args.putString(SELECTION, selection); args.putIntArray(VIEWRESIDS, viewResIDs); args.putStringArray(PROJECTION, projection); args.putString(GROUPBY, groupBy); args.putString(ORDERBY, orderBy); args.putInt(LAYOUT, layout); args.putInt(VIEWHOLDERLAYOUT, viewHolderLayout); args.putParcelable(DBDEFINITION, tbd); }
private void addTabletViews() { FragmentTransaction lft = getChildFragmentManager().beginTransaction(); contentListFragment = new ContentListFragment(); Bundle bundle = new Bundle(); bundle.putStringArray(MainActivity.EXTRA_CONTENT_NAMES, contentNames); bundle.putIntArray(MainActivity.EXTRA_CONTENT_IMAGES, contentImages); contentListFragment.setArguments(bundle); lft.replace(R.id.leftFragmentContainer, contentListFragment).commit(); // rft.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); // rft.replace(R.id.rightFragmentContainer, getDefaultFragmentWithArgs()).commit(); // ((BaseDrawerActivity) getActivity()).getSecondaryToolbar().setTitle(""); }
private void pickAlbum(int slotIndex) { if (!mIsActive) return; MediaSet targetSet = mAlbumSetDataAdapter.getMediaSet(slotIndex); if (targetSet == null) return; // Content is dirty, we shall reload soon if (targetSet.getTotalMediaItemCount() == 0) { showEmptyAlbumToast(Toast.LENGTH_SHORT); return; } hideEmptyAlbumToast(); String mediaPath = targetSet.getPath().toString(); Bundle data = new Bundle(getData()); int[] center = new int[2]; getSlotCenter(slotIndex, center); data.putIntArray(AlbumPage.KEY_SET_CENTER, center); if (mGetAlbum && targetSet.isLeafAlbum()) { Activity activity = mActivity; Intent result = new Intent().putExtra(AlbumPicker.KEY_ALBUM_PATH, targetSet.getPath().toString()); activity.setResult(Activity.RESULT_OK, result); activity.finish(); } else if (targetSet.getSubMediaSetCount() > 0) { data.putString(AlbumSetPage.KEY_MEDIA_PATH, mediaPath); mActivity .getStateManager() .startStateForResult(AlbumSetPage.class, REQUEST_DO_ANIMATION, data); } else { if (!mGetContent && (targetSet.getSupportedOperations() & MediaObject.SUPPORT_IMPORT) != 0) { data.putBoolean(AlbumPage.KEY_AUTO_SELECT_ALL, true); } else if (!mGetContent && albumShouldOpenInFilmstrip(targetSet)) { data.putParcelable( PhotoPage.KEY_OPEN_ANIMATION_RECT, mSlotView.getSlotRect(slotIndex, mRootPane)); data.putInt(PhotoPage.KEY_INDEX_HINT, 0); data.putString(PhotoPage.KEY_MEDIA_SET_PATH, mediaPath); data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP, true); data.putBoolean(PhotoPage.KEY_IN_CAMERA_ROLL, targetSet.isCameraRoll()); mActivity .getStateManager() .startStateForResult(PhotoPage.class, AlbumPage.REQUEST_PHOTO, data); return; } data.putString(AlbumPage.KEY_MEDIA_PATH, mediaPath); // We only show cluster menu in the first AlbumPage in stack boolean inAlbum = mActivity.getStateManager().hasStateClass(AlbumPage.class); data.putBoolean(AlbumPage.KEY_SHOW_CLUSTER_MENU, !inAlbum); mActivity.getStateManager().startStateForResult(AlbumPage.class, REQUEST_DO_ANIMATION, data); } }
public static void startGameListIntent(GameCollection games, String header, Context c) { Intent i = new Intent("dk.nezbo.bggrandom.GAMELIST"); Bundle b = new Bundle(); // create package int[] ids = new int[games.getCount()]; for (int index = 0; index < games.getCount(); index++) ids[index] = games.getIndex(index).getId(); b.putIntArray("ids", ids); b.putString("header", header); i.putExtras(b); c.startActivity(i); }
/** Save the state of the panes */ @Override public void onSaveInstanceState(Bundle savedInstanceState) { int[] panesType = new int[panesLayout.getNumPanes()]; boolean[] panesFocused = new boolean[panesLayout.getNumPanes()]; for (int i = 0; i < panesLayout.getNumPanes(); i++) { PaneView p = panesLayout.getPane(i); panesType[i] = p.type; panesFocused[i] = p.focused; } savedInstanceState.putIntArray("PanesLayout_panesType", panesType); savedInstanceState.putBooleanArray("PanesLayout_panesFocused", panesFocused); savedInstanceState.putInt("PanesLayout_currentIndex", panesLayout.getCurrentIndex()); }
/** * Utility method for implementations to create the base argument bundle * * @param pickerId The id of the item picker * @param title The title for the dialog * @param positiveButtonText The text of the positive button * @param negativeButtonText The text of the negative button * @param enableMultipleSelection Whether or not to allow selecting multiple items * @param selectedItemIndices The positions of the items already selected * @return The arguments bundle */ protected static Bundle buildCommonArgsBundle( int pickerId, String title, String positiveButtonText, String negativeButtonText, boolean enableMultipleSelection, int[] selectedItemIndices) { Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putString(ARG_TITLE, title); args.putString(ARG_POSITIVE_BUTTON_TEXT, positiveButtonText); args.putString(ARG_NEGATIVE_BUTTON_TEXT, negativeButtonText); args.putBoolean(ARG_ENABLE_MULTIPLE_SELECTION, enableMultipleSelection); args.putIntArray(ARG_SELECTED_ITEMS_INDICES, selectedItemIndices); return args; }
/** * @param bitmap Widget image to send * @param id ID of this widget - should be unique, and sensibly identify the widget * @param description User friendly widget name (will be displayed in the widget picker) * @param priority A value that indicates how important this widget is, for use when deciding * which widgets to discard. Lower values are more likely to be discarded. * @return Filled-in intent, ready for broadcast. */ private static Intent createUpdateIntent( Bitmap bitmap, String id, String description, int priority) { int pixelArray[] = new int[bitmap.getWidth() * bitmap.getHeight()]; bitmap.getPixels(pixelArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight()); Intent intent = new Intent("org.metawatch.manager.WIDGET_UPDATE"); Bundle b = new Bundle(); b.putString("id", id); b.putString("desc", description); b.putInt("width", bitmap.getWidth()); b.putInt("height", bitmap.getHeight()); b.putInt("priority", priority); b.putIntArray("array", pixelArray); intent.putExtras(b); return intent; }
@Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); mBitmapAlpha = new float[mCount]; mMessageNumber = new int[mCount]; mNews = new boolean[mCount]; for (int i = 0; i < mCount; i++) { mBitmapAlpha[i] = mTabstrips.get(i).getBitmapAlpha(); mMessageNumber[i] = mTabstrips.get(i).getMessageNumber(); mNews[i] = mTabstrips.get(i).getNews(); } bundle.putParcelable(INSTANCE_STATUS, super.onSaveInstanceState()); bundle.putFloatArray(STATUS_ALPHAS, mBitmapAlpha); bundle.putIntArray(STATUS_MESSAGENUMBER, mMessageNumber); bundle.putBooleanArray(STATUS_NEWS, mNews); return bundle; }
public void onClick1(View v) { try { Intent i = new Intent(mainActivity.this, activity1.class); Bundle numbers1 = new Bundle(); int[] nums = {100, 356, 1587, 4589, 3300}; numbers1.putInt("requestCode1", REQ); numbers1.putInt("number1", 100); numbers1.putInt("number2", 356); numbers1.putInt("number3", 1587); numbers1.putInt("number4", 4589); numbers1.putInt("number5", 3300); numbers1.putIntArray("nums", nums); i.putExtras(numbers1); startActivityForResult(i, REQ); } catch (Exception e) { Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } }
public Bundle store() { Bundle bundle = new Bundle(); int n = items.size(); int x[] = new int[n]; int y[] = new int[n]; long d[] = new long[n]; n = 0; for (Item item : items) { x[n] = item.x; y[n] = item.y; d[n] = item.duration; ++n; } bundle.putIntArray("x", x); bundle.putIntArray("y", y); bundle.putLongArray("d", d); bundle.putLong("cost", cost); return bundle; }
@Override protected void setInternalArguments(Bundle args) { super.setInternalArguments(args); args.putIntArray(VIEWRESIDS, viewResIDs); args.putIntArray(FROMRESIDS, fromResIDs); args.putInt(LAYOUT, layout); mUmsatz = args.getParcelable(UMSATZ); showDetails = args.getBoolean(SHOWDIALOG, false); if (mUmsatz.isDetail()) { showDetails = true; Long id = mUmsatz.getAsLong(R.string.column_transferID); try { mUmsatz = new BankUmsatz(id); args.putParcelable(UMSATZ, mUmsatz); } catch (AWApplicationGeschaeftsObjekt.LineNotFoundException e) { // TODO Execption bearbeiten e.printStackTrace(); } } }