List of usage examples for android.os Bundle putSerializable
@Override public void putSerializable(@Nullable String key, @Nullable Serializable value)
From source file:ch.bfh.evoting.alljoyn.BusHandler.java
/** * Initialize AllJoyn/*from w ww . j av a 2 s .co m*/ */ private void doInit() { PeerGroupListener pgListener = new PeerGroupListener() { @Override public void foundAdvertisedName(String groupName, short transport) { Intent i = new Intent("advertisedGroupChange"); LocalBroadcastManager.getInstance(context).sendBroadcast(i); } @Override public void lostAdvertisedName(String groupName, short transport) { Intent i = new Intent("advertisedGroupChange"); LocalBroadcastManager.getInstance(context).sendBroadcast(i); } @Override public void groupLost(String groupName) { if (mGroupManager.listHostedGroups().contains(groupName) && mGroupManager.getNumPeers(groupName) == 1) { //signal was send because admin stays alone in the group //not necessary to manage this case for us Log.d(TAG, "Group destroyed event ignored"); return; } Log.d(TAG, "Group " + groupName + " was destroyed."); Intent i = new Intent("groupDestroyed"); i.putExtra("groupName", groupName); LocalBroadcastManager.getInstance(context).sendBroadcast(i); } @Override public void peerAdded(String busId, String groupName, int numParticipants) { Log.d(TAG, "peer added"); if (amIAdmin) { Log.d(TAG, "Sending salt " + Base64.encodeToString(messageEncrypter.getSalt(), Base64.DEFAULT)); Message msg = obtainMessage(BusHandler.PING); Bundle data = new Bundle(); data.putString("groupName", lastJoinedNetwork); data.putString("pingString", Base64.encodeToString(messageEncrypter.getSalt(), Base64.DEFAULT)); data.putBoolean("encrypted", false); data.putSerializable("type", Type.SALT); msg.setData(data); sendMessage(msg); } //update UI LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent("participantStateUpdate")); } @Override public void peerRemoved(String peerId, String groupName, int numPeers) { //update UI Log.d(TAG, "peer left"); Intent intent = new Intent("participantStateUpdate"); intent.putExtra("action", "left"); intent.putExtra("id", peerId); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); super.peerRemoved(peerId, groupName, numPeers); } }; ArrayList<BusObjectData> busObjects = new ArrayList<BusObjectData>(); Handler mainHandler = new Handler(context.getMainLooper()); Runnable myRunnable = new Runnable() { @Override public void run() { org.alljoyn.bus.alljoyn.DaemonInit.PrepareDaemon(context); } }; mainHandler.post(myRunnable); busObjects.add(new BusObjectData(mSimpleService, "/SimpleService")); mGroupManager = new PeerGroupManager(SERVICE_NAME, pgListener, busObjects); mGroupManager.registerSignalHandlers(this); }
From source file:com.asksven.betterbatterystats.StatsActivity.java
/** * Save state, the application is going to get moved out of memory * see http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state *//*from w w w . j a va 2 s.com*/ @Override public void onSaveInstanceState(Bundle savedInstanceState) { super.onSaveInstanceState(savedInstanceState); //Log.i(TAG, "onSaveInstanceState references: refFrom=" + m_refFromName + " refTo=" + m_refToName); savedInstanceState.putSerializable("stattypeFrom", m_refFromName); savedInstanceState.putSerializable("stattypeTo", m_refToName); savedInstanceState.putSerializable("stat", m_iStat); //StatsProvider.getInstance(this).writeToBundle(savedInstanceState); }
From source file:com.facebook.LegacyTokenCacheTest.java
@Test public void testAllTypes() { Bundle originalBundle = new Bundle(); putBoolean(BOOLEAN_KEY, originalBundle); putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle); putByte(BYTE_KEY, originalBundle);/* w w w . j av a 2s . co m*/ putByteArray(BYTE_ARRAY_KEY, originalBundle); putShort(SHORT_KEY, originalBundle); putShortArray(SHORT_ARRAY_KEY, originalBundle); putInt(INT_KEY, originalBundle); putIntArray(INT_ARRAY_KEY, originalBundle); putLong(LONG_KEY, originalBundle); putLongArray(LONG_ARRAY_KEY, originalBundle); putFloat(FLOAT_KEY, originalBundle); putFloatArray(FLOAT_ARRAY_KEY, originalBundle); putDouble(DOUBLE_KEY, originalBundle); putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle); putChar(CHAR_KEY, originalBundle); putCharArray(CHAR_ARRAY_KEY, originalBundle); putString(STRING_KEY, originalBundle); putStringList(STRING_LIST_KEY, originalBundle); originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB); ensureApplicationContext(); LegacyTokenHelper cache = new LegacyTokenHelper(RuntimeEnvironment.application); cache.save(originalBundle); LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application); Bundle cachedBundle = cache2.load(); assertEquals(originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY)); assertArrayEquals(originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY), cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY)); assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY)); assertArrayEquals(originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY)); assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY)); assertArrayEquals(originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY)); assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY)); assertArrayEquals(originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY)); assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY)); assertArrayEquals(originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY)); assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY)); assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY), TestUtils.DOUBLE_EQUALS_DELTA); assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY), cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY)); assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY)); assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY)); assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY)); assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(STRING_LIST_KEY)); assertEquals(originalBundle.getSerializable(SERIALIZABLE_KEY), cachedBundle.getSerializable(SERIALIZABLE_KEY)); }
From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsReceivePaymentMainFragment.java
private void SmsReceivePaymentSubmitTask() { SmsReceivePaymentSubmitParser netParser = new SmsReceivePaymentSubmitParser(); requsetData = new CommonData(); requsetData.putValue("fumobile", mPhone); requsetData.putValue("money", mMoney); requsetData.putValue("payfee", mFee); requsetData.putValue("memo", mMessage); requsetData.putValue("shoucardno", creditCard.getBkcardno()); requsetData.putValue("shoucardman", creditCard.getBkcardbankman()); requsetData.putValue("shoucardmobile", creditCard.getBkcardbankphone()); requsetData.putValue("shoucardbank", creditCard.getBkcardbank()); asyncHotelServiceTask = new AsyncLoadWork<String>(getActivity(), netParser, requsetData, new AsyncLoadWorkListener() { @Override/*from w w w . j a va2s . c o m*/ public void onSuccess(Object protocolDataList, Bundle bundle) { Bundle b = new Bundle(); b.putSerializable("requsetData", requsetData); BuyLicenseKeyUtils.switchFragment(getFragmentManager().beginTransaction(), SmsSuccessFragment.newInstance(b), 1); } @Override public void onFailure(String error) { // showDialogMessage(LoginUtil.mLoginStatus.message+"",5000); } }, false, false); asyncHotelServiceTask.execute("ApiSMSReceiptInfo ", "addSMSReceipt"); }
From source file:com.android.returncandidate.activities.SdmScannerActivity.java
/** * onRestart event handler//w w w . j ava2s . c o m */ @Override protected void onRestart() { // Print log end process LogManager.i(TAG, Message.TAG_SCANNER_ACTIVITY + Message.MESSAGE_ACTIVITY_END); // Print log move screen LogManager.i(TAG, String.format(Message.MESSAGE_ACTIVITY_MOVE, Message.SCANNER_ACTIVITY_NAME, Message.UNLOCK_ACTIVITY_NAME)); super.onRestart(); if (timeout < (System.currentTimeMillis() - Constants.TIME_OUT)) { Intent intent = new Intent(this, UnlockScreenActivity.class); Bundle bundle = new Bundle(); HashMap<String, LinkedList<String[]>> hashMapArrBook = new HashMap<>(); hashMapArrBook.put(Constants.COLUMN_INFOR_LIST_SCAN, arrBookInlist); bundle.putString(Constants.COLUMN_USER_ID, userID); bundle.putString(Constants.COLUMN_SHOP_ID, shopID); bundle.putString(Constants.COLUMN_SERVER_NAME, serverName); bundle.putString(Constants.COLUMN_LICENSE, license); bundle.putSerializable(Constants.COLUMN_INFOR_LIST_SCAN, hashMapArrBook); intent.putExtras(bundle); startActivity(intent); finish(); Log.d("LINCONGPVUNCLOCK", license); } // Activate HSM license Log.d("LINCONGPVUNCLOCK1", license); ActivationResult activationResult = ActivationManager.activate(this, license); Toast.makeText(this, "Activation result: " + activationResult, Toast.LENGTH_LONG).show(); decCom = (HSMDecodeComponent) findViewById(R.id.hsm_decodeComponent); // HSM init hsmDecoder = HSMDecoder.getInstance(this); // Declare symbology if (aSwitchOCR.isChecked()) { flagSwitchOCR = Constants.FLAG_1; hsmDecoder.enableSymbology(Symbology.OCR); hsmDecoder.setOCRActiveTemplate(OCRActiveTemplate.ISBN); hsmDecoder.disableSymbology(Symbology.EAN13); } else { flagSwitchOCR = Constants.FLAG_0; hsmDecoder.enableSymbology(Symbology.EAN13); //hsmDecoder.setOCRActiveTemplate(OCRActiveTemplate.ISBN); hsmDecoder.disableSymbology(Symbology.OCR); } if (!isEnableScan) { hsmDecoder.disableSymbology(Symbology.EAN13); hsmDecoder.disableSymbology(Symbology.OCR); } //hsmDecoder.enableSymbology(Symbology.EAN13); // Declare HSM component UI hsmDecoder.enableFlashOnDecode(false); hsmDecoder.enableSound(false); hsmDecoder.enableAimer(false); hsmDecoder.setWindowMode(WindowMode.CENTERING); hsmDecoder.setWindow(18, 42, 0, 100); // Assign listener hsmDecoder.addResultListener(this); }
From source file:com.arya.portfolio.view_controller.fragment.UseCasesFragment.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Intent intent;//from ww w.j a v a2s . c o m Bundle bundle = new Bundle(); if (txtProductEngineering.isSelected()) { intent = new Intent(getActivity(), PortfolioSingleActivity.class); bundle.putSerializable("listData", listData); bundle.putInt("position", i); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE); } else if (txtIndustry.isSelected()) { /* intent = new Intent(getActivity(), IndustrySingleActivity.class); bundle.putSerializable("listIndData", listIndData); bundle.putInt("position", i); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE);*/ intent = new Intent(getActivity(), PortfolioList.class); String industryCategory = listIndData.get(i).categoryName.trim(); ArrayList<PortfolioData> portfolioListIndustry = DBManagerAP.getInstance().getProductAccToCategory("", "", industryCategory); bundle.putSerializable("listData", portfolioListIndustry); bundle.putString("title", industryCategory); bundle.putInt("position", i); intent.putExtras(bundle); startActivity(intent); } else { intent = new Intent(getActivity(), PortfolioList.class); String technologyName = listTechData.get(i).technologyName.toLowerCase().trim(); ArrayList<PortfolioData> portfolioList = DBManagerAP.getInstance().getProductAccToCategory("", technologyName, ""); bundle.putSerializable("listData", portfolioList); bundle.putString("title", listTechData.get(i).technologyName); bundle.putInt("position", i); intent.putExtras(bundle); startActivity(intent); } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.InAppFlashingFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelableArrayList(EXTRA_PENDING_ACTIONS, mPendingActions); outState.putParcelable(EXTRA_SELECTED_URI, mSelectedUri); outState.putString(EXTRA_SELECTED_URI_FILE_NAME, mSelectedUriFileName); outState.putParcelable(EXTRA_SELECTED_BACKUP_DIR_URI, mSelectedBackupDirUri); outState.putString(EXTRA_SELECTED_BACKUP_NAME, mSelectedBackupName); outState.putStringArray(EXTRA_SELECTED_BACKUP_TARGETS, mSelectedBackupTargets); outState.putString(EXTRA_SELECTED_ROM_ID, mSelectedRomId); outState.putString(EXTRA_ZIP_ROM_ID, mZipRomId); outState.putSerializable(EXTRA_ADD_TYPE, mAddType); outState.putInt(EXTRA_TASK_ID_VERIFY_ZIP, mTaskIdVerifyZip); outState.putBoolean(EXTRA_QUERYING_METADATA, mQueryingMetadata); }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(Constants.FRAGMENT_LIST, (Serializable) entries); outState.putSerializable(Constants.FRAGMENT_LIST2, (Serializable) albums); outState.putSerializable(Constants.FRAGMENT_EXTRA, (Serializable) artistInfo); }
From source file:com.noah.lol.network.RequestNetwork.java
protected void asyncRequestGet(final String url, final NetworkListener<String> listener) { if (url == null) { return;/*from www . j a va2 s .c om*/ } try { environmentCheck(); } catch (EnvironmentException e) { if (listener != null) { e.setStatus(BAD_REQUEST_ENVIRONMENT_CONFIG); listener.onNetworkFail(BAD_REQUEST_ENVIRONMENT_CONFIG, e); } return; } final Handler handler = new Handler() { @Override public void handleMessage(Message msg) { Bundle bundle = msg.getData(); switch (msg.what) { case REQUEST_SUCCESS: String responseBody = bundle.getString(RESPONSE_KEY); if (listener != null && responseBody != null) { listener.onSuccess(responseBody); } break; case REQUEST_FAIL: NetworkException e = (NetworkException) bundle.getSerializable(EXCEPTION_KEY); if (listener != null) { listener.onNetworkFail(e.getStatus(), e); } break; } } }; new Thread(new Runnable() { @Override public void run() { String responseBody = null; Message message = new Message(); try { responseBody = syncRequestGet(url); Bundle bundle = new Bundle(); bundle.putString(RESPONSE_KEY, responseBody); message = Message.obtain(handler, REQUEST_SUCCESS); message.setData(bundle); handler.sendMessage(message); } catch (NetworkException e) { Bundle bundle = new Bundle(); bundle.putSerializable(EXCEPTION_KEY, e); message = Message.obtain(handler, REQUEST_FAIL); message.setData(bundle); handler.sendMessage(message); e.printStackTrace(); } } }).start(); }
From source file:dev.memento.MementoBrowser.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log.d(LOG_TAG, "-- onSaveInstanceState"); outState.putSerializable("mDateChosen", mDateChosen); outState.putSerializable("mDateDisplayed", mDateDisplayed); outState.putString("mCurrentUrl", mCurrentUrl); outState.putString("mOriginalUrl", mOriginalUrl); outState.putString("mPageTitle", mPageTitle); Log.d(LOG_TAG, "** Num of mementos: " + mMementos.size()); outState.putSerializable("mMementos", mMementos); }