Example usage for android.os Bundle containsKey

List of usage examples for android.os Bundle containsKey

Introduction

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

Prototype

public boolean containsKey(String key) 

Source Link

Document

Returns true if the given key is contained in the mapping of this Bundle.

Usage

From source file:com.facebook.share.internal.ShareInternalUtility.java

/**
 * Returns the id of the published post. This is only returned if the user has previously
 * given the app publish permissions./*from w w w  .j  a  va 2s.co  m*/
 *
 * @param result the bundle passed back to onActivityResult
 * @return the id of the published post
 */
public static String getShareDialogPostId(Bundle result) {
    if (result.containsKey(ShareConstants.RESULT_POST_ID)) {
        return result.getString(ShareConstants.RESULT_POST_ID);
    }
    if (result.containsKey(ShareConstants.EXTRA_RESULT_POST_ID)) {
        return result.getString(ShareConstants.EXTRA_RESULT_POST_ID);
    }
    return result.getString(ShareConstants.WEB_DIALOG_RESULT_PARAM_POST_ID);
}

From source file:Main.java

public static void registerNewSourceSinkConnection(int counter, Bundle bundle) {
    Log.i("PEP", "in registerNewSourceSinkConnection(int counter, Bundle bundle)");
    int taintInfoKeyCounter = 0;

    if (bundle != null) {
        for (String intentKey : bundle.keySet()) {
            if (intentKey.startsWith(keyBaseName)) {
                String possibleNumber = intentKey.substring(keyBaseName.length());
                if (possibleNumber.length() > 0 && TextUtils.isDigitsOnly(possibleNumber)) {
                    int currentCounter = Integer.parseInt(possibleNumber);
                    if (taintInfoKeyCounter < currentCounter)
                        taintInfoKeyCounter = currentCounter;
                }/*w  w  w  .  j a  va2  s.co m*/
            }
        }

        if (taintInfoKeyCounter == 0) {
            Log.i("PEP", "bundle:" + bundle.toString());
            if (bundle.containsKey(keyBaseName)) {
                String taintSourceCats = bundle.getString(keyBaseName);
                String[] allCats = taintSourceCats.split(",");
                sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats)));
            }
        } else {
            if (bundle.containsKey(keyBaseName + taintInfoKeyCounter)) {
                String taintSourceCats = bundle.getString(keyBaseName + taintInfoKeyCounter);
                String[] allCats = taintSourceCats.split(",");
                sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats)));
            }
        }
    }
}

From source file:Main.java

public static void registerNewSourceSinkConnection(int counter, Bundle bundle) {
    Log.i("PEP", "in registerNewSourceSinkConnection(int counter, Bundle bundle)" + counter + " "
            + bundle.toString());/*from  ww  w .  ja va2s .  co m*/
    int taintInfoKeyCounter = 0;

    if (bundle != null) {
        for (String intentKey : bundle.keySet()) {
            if (intentKey.startsWith(keyBaseName)) {
                String possibleNumber = intentKey.substring(keyBaseName.length());
                if (possibleNumber.length() > 0 && TextUtils.isDigitsOnly(possibleNumber)) {
                    int currentCounter = Integer.parseInt(possibleNumber);
                    if (taintInfoKeyCounter < currentCounter)
                        taintInfoKeyCounter = currentCounter;
                }
            }
        }

        if (taintInfoKeyCounter == 0) {
            Log.i("PEP", "bundle:" + bundle.toString());
            if (bundle.containsKey(keyBaseName)) {
                String taintSourceCats = bundle.getString(keyBaseName);
                String[] allCats = taintSourceCats.split(",");
                sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats)));
            }
        } else {
            if (bundle.containsKey(keyBaseName + taintInfoKeyCounter)) {
                String taintSourceCats = bundle.getString(keyBaseName + taintInfoKeyCounter);
                String[] allCats = taintSourceCats.split(",");
                sourceSinkConnection.put(counter, new HashSet<String>(Arrays.asList(allCats)));
            }
        }
    }
}

From source file:DetailFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    Bundle bundle = getArguments();
    if (bundle != null && bundle.containsKey(KEY_COUNTRY_NAME)) {
        showSelectedCountry(bundle.getString(KEY_COUNTRY_NAME));
    }//  w w w .j a  va  2  s.c  om
}

From source file:com.abcvoipsip.ui.dialpad.DialerAutocompleteDetailsFragment.java

private void proposeRestoreFromBundle(Bundle b) {
    if (b != null && b.containsKey(EXTRA_FILTER_CONSTRAINT)) {
        filter(b.getCharSequence(EXTRA_FILTER_CONSTRAINT));
    }/*from w ww . j av a2 s .c om*/
}

From source file:com.example.android.networkconnect.SimpleTextFragment.java

/**
 * Processes the arguments passed into this Fragment via setArguments method.
 * Currently the method only looks for text or a textID, nothing else.
 *///ww  w. j a va2  s  . co  m
public void processArguments() {
    // For most objects we'd handle the multiple possibilities for initialization variables
    // as multiple constructors.  For Fragments, however, it's customary to use
    // setArguments / getArguments.
    if (getArguments() != null) {
        Bundle args = getArguments();
        if (args.containsKey(TEXT_KEY)) {
            mText = args.getString(TEXT_KEY);
            Log.d("Constructor", "Added Text.");
        } else if (args.containsKey(TEXT_ID_KEY)) {
            mTextId = args.getInt(TEXT_ID_KEY);
            mText = getString(mTextId);
        }
    }
}

From source file:com.corumgaz.mobilsayac.VoiceRecognizer.LanguageDetailsChecker.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle results = getResultExtras(true);

    // get the list of supported languages
    if (results.containsKey(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES)) {
        // Convert the map to json
        supportedLanguages = results.getStringArrayList(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES);
        JSONArray jsonLanguages = new JSONArray(supportedLanguages);
        callbackContext.success(jsonLanguages);
    } else {/*from  w  w  w.ja va  2  s.co m*/
        callbackContext.error("Could not retrieve the list of supported languages");
    }
}

From source file:android.support.content.ContentPager.java

/**
 * @return Bundle populated with existing extras (if any) as well as
 * all usefule paging related extras./*from  w  w w . j  av a  2s  .  co m*/
 */
static Bundle buildExtras(@Nullable Bundle extras, int recordCount, @CursorDisposition int cursorDisposition) {

    if (extras == null || extras == Bundle.EMPTY) {
        extras = new Bundle();
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        extras = extras.deepCopy();
    }
    // else we modify cursor extras directly, cuz that's our only choice.

    extras.putInt(CURSOR_DISPOSITION, cursorDisposition);
    if (!extras.containsKey(EXTRA_TOTAL_COUNT)) {
        extras.putInt(EXTRA_TOTAL_COUNT, recordCount);
    }

    if (!extras.containsKey(EXTRA_HONORED_ARGS)) {
        extras.putStringArray(EXTRA_HONORED_ARGS,
                new String[] { ContentPager.QUERY_ARG_OFFSET, ContentPager.QUERY_ARG_LIMIT });
    }

    return extras;
}

From source file:at.jclehner.rxdroid.DatePickerFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar cal;

    final Bundle args = getArguments();
    if (args == null || !args.containsKey(ARG_DATE))
        cal = DateTime.nowCalendar();//from ww  w.  ja  v  a  2  s.  c  o  m
    else
        cal = DateTime.calendarFromDate((Date) args.getSerializable(ARG_DATE));

    final int d = cal.get(Calendar.DAY_OF_MONTH);
    final int m = cal.get(Calendar.MONTH);
    final int y = cal.get(Calendar.YEAR);

    if (Version.SDK_IS_JELLYBEAN_OR_NEWER) {
        // Workaround for Android issue #34833
        final Dialog dialog = new DatePickerDialog(getActivity(), null, y, m, d);
        dialog.setOnShowListener(this);
        return dialog;
    } else
        return new DatePickerDialog(getActivity(), mListener, y, m, d);
}

From source file:com.chess.genesis.activity.GameListFrag.java

protected void sendGame(final Bundle gamedata) {
    try {//w  w  w  .  j av a  2 s .  c  om
        final String gamename = gamedata.containsKey("gameid")
                ? gamedata.getString("white") + " V. " + gamedata.getString("black")
                : gamedata.getString("name");
        final String filename = gamename + ".txt";
        final String gamestr = GameParser.export(gamedata).toString();
        final Uri uri = FileUtils.writeFile(filename, gamestr);
        final Intent intent = new Intent(Intent.ACTION_SEND);

        intent.putExtra(Intent.EXTRA_STREAM, uri);
        intent.setType("application/json");
        startActivity(intent);
    } catch (final JSONException e) {
        Toast.makeText(act, "Corrupt Game Data", Toast.LENGTH_LONG).show();
    } catch (final FileNotFoundException e) {
        Toast.makeText(act, "File Not Found", Toast.LENGTH_LONG).show();
    } catch (final IOException e) {
        Toast.makeText(act, "Error Reading File", Toast.LENGTH_LONG).show();
    }
}