Source:
public void setDataForFields(Bundle bundle) throws JavaRosaException { FormController formController = Collect.getInstance().getFormController(); if (formController == null) { return; } if (bundle != null) { Set<String> keys = bundle.keySet(); for (String key : keys) { for (QuestionWidget questionWidget : widgets) { FormEntryPrompt prompt = questionWidget.getFormEntryPrompt(); TreeReference treeReference = (TreeReference) prompt.getFormElement().getBind().getReference(); if (treeReference.getNameLast().equals(key)) { switch (prompt.getDataType()) { case Constants.DATATYPE_TEXT: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asStringData(bundle.get(key))); ((StringWidget) questionWidget).setDisplayValueFromModel(); break; case Constants.DATATYPE_INTEGER: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asIntegerData(bundle.get(key))); ((StringWidget) questionWidget).setDisplayValueFromModel(); break; case Constants.DATATYPE_DECIMAL: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asDecimalData(bundle.get(key))); ((StringWidget) questionWidget).setDisplayValueFromModel(); break; case Constants.DATATYPE_BINARY: try { Uri uri = (Uri) bundle.get(key); try { File destFile = FileUtils.createDestinationMediaFile(formController.getInstanceFile().getParent(), ContentResolverHelper.getFileExtensionFromUri(getContext(), uri)); FileUtils.saveAnswerFileFromUri(uri, destFile, getContext()); ((WidgetDataReceiver) questionWidget).setData(destFile); } catch (SecurityException e) { Timber.w(e); } } catch (ClassCastException e) { Timber.w(e); } break; default: throw new RuntimeException( getContext().getString(R.string.ext_assign_value_error, treeReference.toString(false))); } break; } } } } }

Target:
public void setDataForFields(Bundle bundle) throws JavaRosaException { FormController formController = Collect.getInstance().getFormController(); if (formController == null) { return; } if (bundle != null) { Set<String> keys = bundle.keySet(); for (String key : keys) { for (QuestionWidget questionWidget : widgets) { FormEntryPrompt prompt = questionWidget.getFormEntryPrompt(); TreeReference treeReference = (TreeReference) prompt.getFormElement().getBind().getReference(); if (treeReference.getNameLast().equals(key)) { switch (prompt.getDataType()) { case Constants.DATATYPE_TEXT: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asStringData(bundle.get(key))); ((StringWidget) questionWidget).setDisplayValueFromModel(); break; case Constants.DATATYPE_INTEGER: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asIntegerData(bundle.get(key))); ((StringWidget) questionWidget).setDisplayValueFromModel(); break; case Constants.DATATYPE_DECIMAL: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asDecimalData(bundle.get(key))); ((StringWidget) questionWidget).setDisplayValueFromModel(); break; case Constants.DATATYPE_BINARY: try { Uri uri = (Uri) bundle.get(key); if (uri != null) { File destFile = FileUtils.createDestinationMediaFile(formController.getInstanceFile().getParent(), ContentResolverHelper.getFileExtensionFromUri(getContext(), uri)); FileUtils.saveAnswerFileFromUri(uri, destFile, getContext()); ((WidgetDataReceiver) questionWidget).setData(destFile); } } catch (Exception | Error e) { Timber.w(e); } break; default: throw new RuntimeException( getContext().getString(R.string.ext_assign_value_error, treeReference.toString(false))); } break; } } } } }