Example usage for android.os Bundle getBundle

List of usage examples for android.os Bundle getBundle

Introduction

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

Prototype

@Nullable
public Bundle getBundle(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:org.i_chera.wolfensteineditor.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Global.initialize(this);
    mDocument = Document.getInstance();
    setContentView(R.layout.activity_main);
    findViewById(android.R.id.content).setBackgroundColor(FLOOR_COLOUR);

    if (savedInstanceState != null) {
        String value = savedInstanceState.getString(EXTRA_CURRENT_PATH);
        if (value != null)
            mCurrentPath = new File(value);
        mLevelBundle = savedInstanceState.getBundle(EXTRA_FRAGMENT_LEVEL);
        mStartBundle = savedInstanceState.getBundle(EXTRA_FRAGMENT_START);
        establishCurrentFragment();/*from   w  w  w  . ja va 2s .  c o m*/
    }

    mStartFragment = (StartFragment) showFragment(StartFragment.class, mStartBundle);
}

From source file:fr.cobaltians.cobalt.activities.CobaltActivity.java

public void popTo(String controller, String page) {
    Intent popToIntent = Cobalt.getInstance(this).getIntentForController(controller, page);

    if (popToIntent != null) {
        Bundle popToExtras = popToIntent.getBundleExtra(Cobalt.kExtras);
        String popToActivityClassName = popToExtras.getString(Cobalt.kActivity);

        try {//  w  w w  .  j  a v a2s. c o  m
            Class<?> popToActivityClass = Class.forName(popToActivityClassName);

            boolean popToControllerFound = false;
            int popToControllerIndex = -1;

            for (int i = sActivitiesArrayList.size() - 1; i >= 0; i--) {
                Activity oldActivity = sActivitiesArrayList.get(i);
                Class<?> oldActivityClass = oldActivity.getClass();

                Bundle oldBundle = oldActivity.getIntent().getExtras();
                Bundle oldExtras = (oldBundle != null) ? oldBundle.getBundle(Cobalt.kExtras) : null;
                String oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null;

                if (oldPage == null && CobaltActivity.class.isAssignableFrom(oldActivityClass)) {
                    Fragment fragment = ((CobaltActivity) oldActivity).getSupportFragmentManager()
                            .findFragmentById(((CobaltActivity) oldActivity).getFragmentContainerId());
                    if (fragment != null) {
                        oldExtras = fragment.getArguments();
                        oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null;
                    }
                }

                if (popToActivityClass.equals(oldActivityClass) && (!CobaltActivity.class
                        .isAssignableFrom(oldActivityClass)
                        || (CobaltActivity.class.isAssignableFrom(oldActivityClass) && page.equals(oldPage)))) {
                    popToControllerFound = true;
                    popToControllerIndex = i;
                    break;
                }
            }

            if (popToControllerFound) {
                while (popToControllerIndex + 1 <= sActivitiesArrayList.size()) {
                    sActivitiesArrayList.get(popToControllerIndex + 1).finish();
                }
            } else if (Cobalt.DEBUG)
                Log.w(Cobalt.TAG, TAG + " - popTo: controller " + controller
                        + (page == null ? "" : " with page " + page) + " not found in history. Abort.");
        } catch (ClassNotFoundException exception) {
            exception.printStackTrace();
        }
    } else if (Cobalt.DEBUG)
        Log.e(Cobalt.TAG, TAG + " - popTo: unable to pop to null controller");
}

From source file:li.klass.fhem.activities.core.TopLevelFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(INITIAL_FRAGMENT_TYPE_KEY)) {
            initialFragmentType = FragmentType.valueOf(savedInstanceState.getString(INITIAL_FRAGMENT_TYPE_KEY));
        }//  w ww  .  j a v a  2 s.c o m

        if (savedInstanceState.containsKey(LAST_SWITCH_TO_BUNDLE_KEY)) {
            lastSwitchToBundle = savedInstanceState.getBundle(LAST_SWITCH_TO_BUNDLE_KEY);
        }
    }
    View view = inflater.inflate(R.layout.content_view, null);
    Reject.ifNull(view);

    View navigationView = view.findViewById(R.id.navigation);
    View contentView = view.findViewById(R.id.content);

    contentId = ViewUtil.getPseudoUniqueId(view, container);
    contentView.setId(contentId);

    navigationId = ViewUtil.getPseudoUniqueId(view, container);
    if (navigationView != null)
        navigationView.setId(navigationId);

    return view;
}

From source file:org.anhonesteffort.flock.ManageSubscriptionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_PROGRESS);

    setContentView(R.layout.simple_fragment_activity);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setTitle(R.string.title_manage_subscription);

    if (savedInstanceState != null && !savedInstanceState.isEmpty()) {
        if (!DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) {
            Log.e(TAG, "where did my dav account bundle go?! :(");
            finish();/*  w ww  . j  a  v  a  2 s .  c om*/
            return;
        }

        davAccount = DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get();
        currentFragment = savedInstanceState.getInt(KEY_CURRENT_FRAGMENT, -1);
        activityRequestCode = Optional.fromNullable(savedInstanceState.getInt(KEY_REQUEST_CODE));
        activityResultCode = Optional.fromNullable(savedInstanceState.getInt(KEY_RESULT_CODE));
        activityResultData = Optional.fromNullable((Intent) savedInstanceState.getParcelable(KEY_RESULT_DATA));
    } else if (getIntent().getExtras() != null) {
        if (!DavAccount.build(getIntent().getExtras().getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) {
            Log.e(TAG, "where did my dav account bundle go?! :(");
            finish();
            return;
        }

        davAccount = DavAccount.build(getIntent().getExtras().getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get();
        currentFragment = getIntent().getExtras().getInt(KEY_CURRENT_FRAGMENT, -1);
        activityRequestCode = Optional.fromNullable(getIntent().getExtras().getInt(KEY_REQUEST_CODE));
        activityResultCode = Optional.fromNullable(getIntent().getExtras().getInt(KEY_RESULT_CODE));
        activityResultData = Optional
                .fromNullable((Intent) getIntent().getExtras().getParcelable(KEY_RESULT_DATA));
    }

    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE);
}

From source file:br.org.funcate.dynamicforms.FragmentDetail.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.details, container, false);
    LinearLayout mainView = (LinearLayout) view.findViewById(R.id.form_linear);
    FragmentDetailActivity fragmentDetailActivity;
    try {/*from w w  w  . j av  a 2s. co m*/
        FragmentActivity activity = getActivity();
        if (selectedFormName == null || sectionObject == null) {
            FragmentList fragmentList = (FragmentList) getFragmentManager().findFragmentById(R.id.listFragment);
            if (fragmentList != null) {
                selectedFormName = fragmentList.getSelectedItemName();
                sectionObject = fragmentList.getSectionObject();
                noteId = fragmentList.getNoteId();
            } else {
                if (activity instanceof FragmentDetailActivity) {
                    // case of portrait mode
                    fragmentDetailActivity = (FragmentDetailActivity) activity;
                    selectedFormName = fragmentDetailActivity.getFormName();
                    sectionObject = fragmentDetailActivity.getSectionObject();
                    noteId = fragmentDetailActivity.getNoteId();
                    workingDirectory = fragmentDetailActivity.getWorkingDirectory();
                    existingFeatureData = fragmentDetailActivity.getFeatureData();
                }
            }
        }
        if (selectedFormName != null) {
            JSONObject formObject = TagsManager.getForm4Name(selectedFormName, sectionObject);

            key2WidgetMap.clear();
            requestCodes2WidgetMap.clear();
            int requestCode = 666;
            keyList.clear();
            key2ConstraintsMap.clear();

            if (formObject != null) {// Test to get form configuration to this layer

                JSONArray formItemsArray = TagsManager.getFormItems(formObject);

                int length = ((formItemsArray != null) ? (formItemsArray.length()) : (0));
                for (int i = 0; i < length; i++) {
                    JSONObject jsonObject = formItemsArray.getJSONObject(i);

                    String key = "-"; //$NON-NLS-1$
                    if (jsonObject.has(TAG_KEY))
                        key = jsonObject.getString(TAG_KEY).trim();

                    String label = key;
                    if (jsonObject.has(TAG_LABEL))
                        label = jsonObject.getString(TAG_LABEL).trim();

                    String type = FormUtilities.TYPE_STRING;
                    if (jsonObject.has(TAG_TYPE)) {
                        type = jsonObject.getString(TAG_TYPE).trim();
                    }

                    boolean readonly = false;
                    if (jsonObject.has(TAG_READONLY)) {
                        String readonlyStr = jsonObject.getString(TAG_READONLY).trim();
                        readonly = Boolean.parseBoolean(readonlyStr);
                    }
                    // if attribute has a non printable char, force readonly mode.
                    if (Utilities.existUnprintableCharacters(key)) {
                        readonly = true;
                    }

                    Constraints constraints = new Constraints();
                    FormUtilities.handleConstraints(jsonObject, constraints);
                    key2ConstraintsMap.put(key, constraints);
                    String constraintDescription = constraints.getDescription();

                    Object o;
                    GView addedView = null;
                    if (type.equals(TYPE_STRING)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 0, 0,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_STRINGAREA)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 0, 7,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_DOUBLE)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 1, 0,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_INTEGER)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 4, 0,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_DATE)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addDateView(FragmentDetail.this, mainView, label, value,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_TIME)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addTimeView(FragmentDetail.this, mainView, label, value,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_LABEL)) {
                        String size = "20"; //$NON-NLS-1$
                        if (jsonObject.has(TAG_SIZE))
                            size = jsonObject.getString(TAG_SIZE);
                        String url = null;
                        if (jsonObject.has(TAG_URL))
                            url = jsonObject.getString(TAG_URL);

                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addTextView(activity, mainView, value, size, false, url);
                    } else if (type.equals(TYPE_LABELWITHLINE)) {
                        String size = "20"; //$NON-NLS-1$
                        if (jsonObject.has(TAG_SIZE))
                            size = jsonObject.getString(TAG_SIZE);
                        String url = null;
                        if (jsonObject.has(TAG_URL))
                            url = jsonObject.getString(TAG_URL);

                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addTextView(activity, mainView, value, size, true, url);
                    } else if (type.equals(TYPE_BOOLEAN)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addBooleanView(activity, mainView, label, value,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_STRINGCOMBO)) {
                        JSONArray comboItems = TagsManager.getComboItems(jsonObject);
                        String[] itemsArray = TagsManager.comboItems2StringArray(comboItems);
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addComboView(activity, mainView, label, value, itemsArray,
                                constraintDescription);
                    } else if (type.equals(TYPE_CONNECTEDSTRINGCOMBO)) {
                        LinkedHashMap<String, List<String>> valuesMap = TagsManager
                                .extractComboValuesMap(jsonObject);
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addConnectedComboView(activity, mainView, label, value,
                                valuesMap, constraintDescription);
                    } else if (type.equals(TYPE_STRINGMULTIPLECHOICE)) {
                        JSONArray comboItems = TagsManager.getComboItems(jsonObject);
                        String[] itemsArray = TagsManager.comboItems2StringArray(comboItems);
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addMultiSelectionView(activity, mainView, label, value,
                                itemsArray, constraintDescription);
                    } else if (type.equals(TYPE_PICTURES)) {

                        o = getValueFromExtras(jsonObject, FormUtilities.IMAGE_MAP);
                        Map<String, Map<String, String>> value = null;
                        String clazz = o.getClass().getSimpleName();
                        if (("bundle").equalsIgnoreCase(clazz)) {
                            Bundle imageMapBundle = (Bundle) o;

                            Bundle imageMapThumbnailBundle = imageMapBundle.getBundle("thumbnail");
                            Bundle imageMapDisplayBundle = imageMapBundle.getBundle("display");

                            if (imageMapThumbnailBundle != null && imageMapDisplayBundle != null) {
                                Set<String> keys = imageMapThumbnailBundle.keySet();
                                Iterator<String> itKeys = keys.iterator();

                                if (keys.size() > 0) {
                                    value = new HashMap<String, Map<String, String>>(keys.size());

                                    while (itKeys.hasNext()) {
                                        String keyMap = itKeys.next();
                                        Map<String, String> imagePaths = new HashMap<String, String>(2);
                                        imagePaths.put("thumbnail",
                                                (String) imageMapThumbnailBundle.get(keyMap));
                                        imagePaths.put("display", (String) imageMapDisplayBundle.get(keyMap));

                                        value.put(keyMap, imagePaths);
                                    }
                                }
                            }
                        }
                        addedView = FormUtilities.addPictureView(this, requestCode, mainView, label, value,
                                constraintDescription);
                    }
                    /*else if (type.equals(TYPE_SKETCH)) {
                    addedView = FormUtilities.addSketchView(noteId, this, requestCode, mainView, label, value, constraintDescription);
                    } */
                    else {
                        Toast.makeText(getActivity().getApplicationContext(),
                                "Type non implemented yet: " + type, Toast.LENGTH_LONG).show();
                    }
                    /*                    } else if (type.equals(TYPE_MAP)) {
                    if (value.length() <= 0) {
                        // need to read image
                        File tempDir = ResourcesManager.getInstance(activity).getTempDir();
                        File tmpImage = new File(tempDir, LibraryConstants.TMPPNGIMAGENAME);
                        if (tmpImage.exists()) {
                            byte[][] imageAndThumbnailFromPath = ImageUtilities.getImageAndThumbnailFromPath(tmpImage.getAbsolutePath(), 1);
                            Date date = new Date();
                            String mapImageName = ImageUtilities.getMapImageName(date);
                            
                            IImagesDbHelper imageHelper = DefaultHelperClasses.getDefaulfImageHelper();
                            long imageId = imageHelper.addImage(longitude, latitude, -1.0, -1.0, date.getTime(), mapImageName, imageAndThumbnailFromPath[0], imageAndThumbnailFromPath[1], noteId);
                            value = "" + imageId;
                        }
                    }
                    addedView = FormUtilities.addMapView(activity, mainView, label, value, constraintDescription);
                                        } else if (type.equals(TYPE_NFCUID)) {
                    addedView = new GNfcUidView(this, null, requestCode, mainView, label, value, constraintDescription);
                                        } else {
                    GPLog.addLogEntry(this, null, null, "Type non implemented yet: " + type);
                                        }*/
                    key2WidgetMap.put(key, addedView);
                    keyList.add(key);
                    requestCodes2WidgetMap.put(requestCode, addedView);
                    requestCode++;
                } // end of the form items loop
            } else {
                String size = "20"; //$NON-NLS-1$
                String url = null;
                String value = getResources().getString(R.string.error_while_loading_form_configuration);
                GView addedView = FormUtilities.addTextView(activity, mainView, value, size, true, url);
                String key = "-"; //$NON-NLS-1$
                key2WidgetMap.put(key, addedView);
                keyList.add(key);
                requestCodes2WidgetMap.put(requestCode, addedView);
            }

            LinearLayout btnLinear = (LinearLayout) mainView.findViewById(R.id.btn_linear);
            if (keyList.size() == 1) {
                Button btnSave = (Button) btnLinear.findViewById(R.id.saveButton);
                btnSave.setEnabled(false);
            }
            mainView.removeView(btnLinear);
            mainView.addView(btnLinear);
        }
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getActivity().getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }

    return view;
}

From source file:com.google.android.apps.authenticator.dataimport.Importer.java

private void importAccountDbFromBundle(Bundle bundle, AccountDb accountDb) {
    // Each account is stored in a Bundle whose key is a string representing the ordinal (integer)
    // position of the account in the database.
    List<String> sortedAccountBundleKeys = new ArrayList<String>(bundle.keySet());
    Collections.sort(sortedAccountBundleKeys, new IntegerStringComparator());
    int importedAccountCount = 0;
    for (String accountBundleKey : sortedAccountBundleKeys) {
        Bundle accountBundle = bundle.getBundle(accountBundleKey);
        String name = accountBundle.getString(KEY_NAME);
        if (name == null) {
            Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": name missing");
            continue;
        }/* w w w .  j av a 2  s .c o  m*/
        if (accountDb.nameExists(name)) {
            // Don't log account name here and below because it's considered PII
            Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": already configured");
            continue;
        }
        String encodedSecret = accountBundle.getString(KEY_ENCODED_SECRET);
        if (encodedSecret == null) {
            Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": secret missing");
            continue;
        }
        String typeString = accountBundle.getString(KEY_TYPE);
        AccountDb.OtpType type;
        if ("totp".equals(typeString)) {
            type = AccountDb.OtpType.TOTP;
        } else if ("hotp".equals(typeString)) {
            type = AccountDb.OtpType.HOTP;
        } else {
            Log.w(LOG_TAG,
                    "Skipping account #" + accountBundleKey + ": unsupported type: \"" + typeString + "\"");
            continue;
        }

        Integer counter = accountBundle.containsKey(KEY_COUNTER) ? accountBundle.getInt(KEY_COUNTER) : null;
        if (counter == null) {
            if (type == AccountDb.OtpType.HOTP) {
                Log.w(LOG_TAG, "Skipping account #" + accountBundleKey + ": counter missing");
                continue;
            } else {
                // TOTP
                counter = AccountDb.DEFAULT_HOTP_COUNTER;
            }
        }

        accountDb.update(name, encodedSecret, name, type, counter);
        importedAccountCount++;
    }

    Log.i(LOG_TAG, "Imported " + importedAccountCount + " accounts");
}

From source file:com.facebook.AppEventsLogger.java

/**
 * Source Application setters and getters
 *///from  ww w .  j  a va2  s .  com
private static void setSourceApplication(Activity activity) {

    ComponentName callingApplication = activity.getCallingActivity();
    if (callingApplication != null) {
        String callingApplicationPackage = callingApplication.getPackageName();
        if (callingApplicationPackage.equals(activity.getPackageName())) {
            // open by own app.
            resetSourceApplication();
            return;
        }
        sourceApplication = callingApplicationPackage;
    }

    // Tap icon to open an app will still get the old intent if the activity was opened by an intent before.
    // Introduce an extra field in the intent to force clear the sourceApplication.
    Intent openIntent = activity.getIntent();
    if (openIntent == null
            || openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) {
        resetSourceApplication();
        return;
    }

    Bundle applinkData = AppLinks.getAppLinkData(openIntent);

    if (applinkData == null) {
        resetSourceApplication();
        return;
    }

    isOpenedByApplink = true;

    Bundle applinkReferrerData = applinkData.getBundle("referer_app_link");

    if (applinkReferrerData == null) {
        sourceApplication = null;
        return;
    }

    String applinkReferrerPackage = applinkReferrerData.getString("package");
    sourceApplication = applinkReferrerPackage;

    // Mark this intent has been used to avoid use this intent again and again.
    openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true);

    return;
}

From source file:com.karura.framework.PluginManager.java

/**
 * Called when the webview attached with the plugin manager is being restored with instance data
 * //w ww .  j  a va 2s .  c  o m
 * Lets try to recreate all plugins with instance data
 * 
 * @param savedInstance
 *            the memory block which contains information about each of the plugins which were persisted in call to onSaveInstanceState
 */
public void onRestoreInstanceState(Bundle savedInstance) {
    // See if there is a valid instance to restore state from
    if (savedInstance == null || !savedInstance.containsKey(PLUGIN_MGR_INSTANCE_DATA_KEY))
        return;

    Bundle pluginMgrInstanceData = savedInstance.getBundle(PLUGIN_MGR_INSTANCE_DATA_KEY);
    _nextPluginId = 0;
    for (String pluginDataKey : pluginMgrInstanceData.keySet()) {

        // only process those data keys which were created by us
        if (!pluginDataKey.startsWith(PLUGIN_INSTANCE_DATA_KEY_PREFIX)) {
            continue;
        }

        // try and retrieve plugin specific instance data
        Bundle pluginInstanceData = pluginMgrInstanceData.getBundle(pluginDataKey);

        if (pluginInstanceData == null)
            continue;

        String clazz = pluginInstanceData.getString(PLUGIN_CLASS_NAME_KEY);
        pluginInstanceData.remove(PLUGIN_CLASS_NAME_KEY);
        Integer pluginId = Integer.valueOf(pluginInstanceData.getString(PLUGIN_ID_KEY));

        // manage the plugin id counter for subsequent allocation of plugins
        if (_nextPluginId < pluginId) {
            _nextPluginId = pluginId;
        }
        pluginInstanceData.remove(PLUGIN_ID_KEY);

        // Since we are passing the instance data for the plugin in this call, we are hoping it
        // will be able to restore its state
        allocateAndCachePlugin(clazz, pluginId, pluginInstanceData);

    }
    // safe increment
    _nextPluginId++;

    // TODO create a list of pluginIds and pass them back to the javascript layer just in case

}

From source file:com.wab.lernapp.LerntestActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ThemeUtils.onActivityCreateSetTheme(this, getThemeNumber());
    setContentView(R.layout.activity_test);
    activity = this;

    if (savedInstanceState != null) {
        mWizardModel.load(savedInstanceState.getBundle("model"));
    }//  w  w  w.j  a  v a  2s  .co  m

    mWizardModel.registerListener(this);

    mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mPagerAdapter);
    mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip);
    mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() {
        @Override
        public void onPageStripSelected(int position) {
            position = Math.min(mPagerAdapter.getCount() - 1, position);
            if (mPager.getCurrentItem() != position) {
                mPager.setCurrentItem(position);
            }
        }
    });

    mNextButton = (Button) findViewById(R.id.next_button);
    mPrevButton = (Button) findViewById(R.id.prev_button);

    mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mStepPagerStrip.setCurrentPage(position);

            if (mConsumePageSelectedEvent) {
                mConsumePageSelectedEvent = false;
                return;
            }

            mEditingAfterReview = false;
            updateBottomBar();
        }
    });

    mNextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                ArrayList<Integer> resultList = new ArrayList<>();
                //was passiert, wenn der Test abgeschlossen wird
                for (Page page : mCurrentPageSequence) {
                    Bundle pageData = page.getData();
                    String result = pageData.getString("_");

                    //wandel Ergebnis in Zahl um
                    switch (result) {
                    case "Trifft voll und ganz zu":
                        resultList.add(3);
                        break;
                    case "Trifft zu":
                        resultList.add(2);
                        break;
                    case "Trifft nicht zu":
                        resultList.add(1);
                        break;
                    case "Trifft berhaupt nicht zu":
                        resultList.add(0);
                        break;
                    default:
                        resultList.add(0);
                        Log.e("Lerntest", "Ergebnis wurde nicht erkannt");
                    }
                }
                //Berechne Ergebnis
                double earmindedPerc = 0;
                for (int i = 6; i < 12; i++) {
                    int result = resultList.get(i);
                    earmindedPerc += result;
                }
                earmindedPerc = (earmindedPerc / 18) * 100;

                Variables.filterOptions[0] = earmindedPerc >= 50;

                double eyemindedPerc = 0;
                for (int i = 0; i < 6; i++) {
                    int result = resultList.get(i);
                    eyemindedPerc += result;
                }
                eyemindedPerc = (eyemindedPerc / 18) * 100;

                Variables.filterOptions[1] = eyemindedPerc >= 50;

                if ((eyemindedPerc < 50) && (earmindedPerc < 50)) {
                    Variables.filterOptions[0] = true;
                    Variables.filterOptions[1] = true;
                }

                //speichere Lerntyp
                Variables.saveDidacticType();

                activity.finish();

            } else {
                if (mEditingAfterReview) {
                    mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
                } else {
                    mPager.setCurrentItem(mPager.getCurrentItem() + 1);
                }
            }
        }
    });

    mPrevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mPager.setCurrentItem(mPager.getCurrentItem() - 1);
        }
    });

    onPageTreeChanged();
    updateBottomBar();
    firstTime();
}

From source file:com.facebook.appevents.AppEventsLogger.java

/**
 * Source Application setters and getters
 *///from   w ww . ja  va  2  s .  co m
private static void setSourceApplication(Activity activity) {

    ComponentName callingApplication = activity.getCallingActivity();
    if (callingApplication != null) {
        String callingApplicationPackage = callingApplication.getPackageName();
        if (callingApplicationPackage.equals(activity.getPackageName())) {
            // open by own app.
            resetSourceApplication();
            return;
        }
        sourceApplication = callingApplicationPackage;
    }

    // Tap icon to open an app will still get the old intent if the activity was opened by an
    // intent before. Introduce an extra field in the intent to force clear the
    // sourceApplication.
    Intent openIntent = activity.getIntent();
    if (openIntent == null
            || openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) {
        resetSourceApplication();
        return;
    }

    Bundle applinkData = AppLinks.getAppLinkData(openIntent);

    if (applinkData == null) {
        resetSourceApplication();
        return;
    }

    isOpenedByApplink = true;

    Bundle applinkReferrerData = applinkData.getBundle("referer_app_link");

    if (applinkReferrerData == null) {
        sourceApplication = null;
        return;
    }

    String applinkReferrerPackage = applinkReferrerData.getString("package");
    sourceApplication = applinkReferrerPackage;

    // Mark this intent has been used to avoid use this intent again and again.
    openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true);

    return;
}