Java Code Examples for android.os.Bundle.containsKey()

The following are Jave code examples for showing how to use containsKey() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Phoenix-for-VK   File: AbsAttachmentsEditPresenter.java   View Source Code Vote up 7 votes
AbsAttachmentsEditPresenter(int accountId, @Nullable Bundle savedInstanceState) {
    super(accountId, savedInstanceState);
    if (nonNull(savedInstanceState)) {
        currentPhotoCameraUri = savedInstanceState.getParcelable(SAVE_CURRENT_PHOTO_CAMERA_URI);
        textBody = savedInstanceState.getString(SAVE_BODY);
        timerValue = savedInstanceState.containsKey(SAVE_TIMER) ? savedInstanceState.getLong(SAVE_TIMER) : null;
    }

    data = new ArrayList<>();
    if(nonNull(savedInstanceState)){
        ArrayList<AttachmenEntry> savedEntries = savedInstanceState.getParcelableArrayList(SAVE_DATA);
        if(nonEmpty(savedEntries)){
            data.addAll(savedEntries);
        }
    }
}
 
Example 2
Project: labtablet   File: DescriptorPickerActivity.java   View Source Code Vote up 6 votes
@Override
public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    // Restore the previously serialized current dropdown position.
    if (savedInstanceState.containsKey(STATE_SELECTED_NAVIGATION_ITEM)) {
        if (getActionBar() == null) {
            ChangelogItem item = new ChangelogItem();
            item.setMessage("DescriptorPicker" + "Couldn't get actionbar");
            item.setTitle(getResources().getString(R.string.developer_error));
            item.setDate(Utils.getDate());
            ChangelogManager.addLog(item, DescriptorPickerActivity.this);
            return;
        }
        getActionBar().setSelectedNavigationItem(
                savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM));
    }
    mDescriptors = FavoriteMgr.getBaseDescriptors(this);
}
 
Example 3
Project: CSipSimple   File: Filter.java   View Source Code Vote up 6 votes
private boolean patternMatches(Context ctxt, String number, Bundle extraHdr, boolean defaultValue) {
    if(CALLINFO_AUTOREPLY_MATCHER_KEY.equals(matchPattern)) {
        if(extraHdr != null &&
               extraHdr.containsKey("Call-Info")) {
               String hdrValue = extraHdr.getString("Call-Info");
               if(hdrValue != null) {
                   hdrValue = hdrValue.trim();
               }
               if(!TextUtils.isEmpty(hdrValue) &&
                       "answer-after=0".equalsIgnoreCase(hdrValue)){
                   return true;
               }
           }
    }else if(BLUETOOTH_MATCHER_KEY.equals(matchPattern)) {
           return BluetoothWrapper.getInstance(ctxt).isBTHeadsetConnected();
       }else {
           try {
               return Pattern.matches(matchPattern, number);
           }catch(PatternSyntaxException e) {
               logInvalidPattern(e);
           }
       }
    return defaultValue;
}
 
Example 4
Project: SmartColorView   File: RectangleColorActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int style = ColorManager.RECTANGLE_COLOR_STYLE01;
    Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.containsKey("style")) {
        style = bundle.getInt("style");
    }
    mRectangleColorModels.clear();
    List<RectangleColorModel> colorList = ColorManager.getRectangleColorList(this, style, false, 15);
    mRectangleColorModels.addAll(colorList);
    GridLayoutManager manager = new GridLayoutManager(this, 5);
    mRecyclerView.setLayoutManager(manager);
    mRectangleColorAdapter = new RectangleColorAdapter(this, mRectangleColorModels);
    mRecyclerView.setAdapter(mRectangleColorAdapter);
    mRectangleColorAdapter.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            mRectangleColorAdapter.changeSelected(position);
        }
    });
}
 
Example 5
Project: MobileAppForPatient   File: PCLinkLibraryDemoActivity.java   View Source Code Vote up 6 votes
/**
    * 當接收到usb時,會由onResume進入
 * When receiving usb, it will be entered by onResume
    */
@Override
protected void onResume() {
	super.onResume();
	        
       boolean fromPl2303 = false;
	Bundle bundle = getIntent().getExtras();
	if(bundle != null && bundle.containsKey(PCLinkLibraryDemoConstant.FromPL2303)) {
		fromPl2303 = bundle.getBoolean(PCLinkLibraryDemoConstant.FromPL2303); 
	}
	
	// 由usb attach呼叫
	//Called by usb attach
	if(getIntent().getAction() != null && getIntent().getAction().equals(UsbManager.ACTION_USB_DEVICE_ATTACHED) ||
			fromPl2303 == true) {
		initDetachedUsbListener();
        initBaudRate();
		initUI(true);
	}
	else {
		initUI(false);
		this.queryBluetoothDevicesAndSetToUi();
	}
	
	clearSharePreferences();
}
 
Example 6
Project: CSipSimple   File: PjSipService.java   View Source Code Vote up 6 votes
public int updateCallOptions(int callId, Bundle options) {
    // TODO : if more options we should redesign this part.
    if (options.containsKey(SipCallSession.OPT_CALL_VIDEO)) {
        boolean add = options.getBoolean(SipCallSession.OPT_CALL_VIDEO);
        SipCallSession ci = getCallInfo(callId);
        if (add && ci.mediaHasVideo()) {
            // We already have one video running -- refuse to send another
            return -1;
        } else if (!add && !ci.mediaHasVideo()) {
            // We have no current video, no way to remove.
            return -1;
        }
        pjsua_call_vid_strm_op op = add ? pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_ADD
                : pjsua_call_vid_strm_op.PJSUA_CALL_VID_STRM_REMOVE;
        if (!add) {
            // TODO : manage remove case
        }
        return pjsua.call_set_vid_strm(callId, op, null);
    }

    return -1;
}
 
Example 7
Project: Phoenix-for-VK   File: FilterEditFragment.java   View Source Code Vote up 6 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
        case REQUEST_CODE_COUTRY:
        case REQUEST_CODE_CITY:
        case REQUEST_CODE_UNIVERSITY:
        case REQUEST_CODE_FACULTY:
        case REQUEST_CODE_CHAIR:
        case REQUEST_CODE_SCHOOL:
        case REQUEST_CODE_SCHOOL_CLASS:
            Bundle extras = data.getExtras();

            int key = extras.getInt(Extra.KEY);
            Integer id = extras.containsKey(Extra.ID) ? extras.getInt(Extra.ID) : null;
            String title = extras.containsKey(Extra.TITLE) ? extras.getString(Extra.TITLE) : null;

            mergeDatabaseOptionValue(key, id == null ? null : new DatabaseOption.Entry(id, title));
            break;
    }
}
 
Example 8
Project: mobile-dashboard   File: UpdateWidgetService.java   View Source Code Vote up 5 votes
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle extras = intent.getExtras();
    if (extras.containsKey("notif") && extras.containsKey("from")) {
        buildUpdate(extras.getString("notif"), extras.getInt("from"));
    }else {
        Log.i(TAG, "onStartCommand Pas de champ notif!");
    }
    return super.onStartCommand(intent, flags, startId);
}
 
Example 9
Project: DeviceInfo   File: HomeFragment.java   View Source Code Vote up 5 votes
/**
 * Get data from bundle
 */
private void getBundleData() {
    Bundle bundle = getArguments();
    if (bundle != null) {
        if (bundle.containsKey(KeyUtil.KEY_MODE)) {
            mode = bundle.getInt(KeyUtil.KEY_MODE);
        }
    }
}
 
Example 10
Project: igrow-android   File: EnvironmentalSensorsFragment.java   View Source Code Vote up 5 votes
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Restore the previously serialized activated item position.
    if (savedInstanceState != null
            && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
        //setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
    }
}
 
Example 11
Project: Responder-Android   File: ObjectCreateFragment.java   View Source Code Vote up 5 votes
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
	super.onViewCreated(view, savedInstanceState);
	mActivity = (MainActivity) getActivity();
	Bundle args = getArguments();
	mSchemaKey = args.getString("schema_key");
	if (args.containsKey("map_location_lat") && args.containsKey("map_location_lon")) {
		mMapLocation = args.getString("map_location_lat") + "," + args.getString("map_location_lon");
	}
	mFormHolder = (LinearLayout) view.findViewById(R.id.form_holder);

	LDLN.readSchema(mActivity, this, mSchemaKey);
}
 
Example 12
Project: GitHub   File: Injector.java   View Source Code Vote up 4 votes
public Character getBoxedChar(Bundle state, String key) {
    if (state.containsKey(key + baseKey)) {
        return state.getChar(key + baseKey);
    }
    return null;
}
 
Example 13
Project: rental-calc   File: ItemizeActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.itemize_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null)
    {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    final Bundle b = getIntent().getExtras();

    if (b == null || b.containsKey("title") == false || b.containsKey("description") == false
            || b.containsKey("items") == false)
    {
        Toast.makeText(this, "Incomplete itemization request", Toast.LENGTH_LONG).show();
        setResult(Activity.RESULT_CANCELED);
        finish();
        return;
    }

    final int titleId = b.getInt("title");
    setTitle(titleId);

    final int definitionId = b.getInt("description");
    TextView definitionView = (TextView)findViewById(R.id.description);
    definitionView.setText(definitionId);

    final HashMap<String, Integer> originalItems = (HashMap<String, Integer>)b.getSerializable("items");
    final ListView list = (ListView) findViewById(R.id.list);

    _items = new LinkedList<>();

    if(originalItems != null)
    {
        for(HashMap.Entry<String, Integer> entry : originalItems.entrySet())
        {
            _items.add(new Itemization(entry.getKey(), entry.getValue()));
        }
    }

    _listAdapter = new ItemizationAdapter(this, _items);
    list.setAdapter(_listAdapter);

    updateTotal();

    _listAdapter.registerDataSetObserver(new DataSetObserver()
    {
        @Override
        public void onChanged()
        {
            updateTotal();
        }
    });

    _listAdapter.setOnValueChangedListener(new ItemizationAdapter.OnValueChangedListener()
    {
        @Override
        public void onValueChanged()
        {
            updateTotal();
        }
    });
}
 
Example 14
Project: mobly-bundled-snippets   File: AccountSnippet.java   View Source Code Vote up 4 votes
/**
 * Adds a Google account to the device.
 *
 * <p>TODO(adorokhine): Support adding accounts of other types with an optional 'type' kwarg.
 *
 * <p>TODO(adorokhine): Allow users to choose whether to enable/disable sync with a kwarg.
 *
 * @param username Username of the account to add (including @gmail.com).
 * @param password Password of the account to add.
 */
@Rpc(
    description = "Add a Google (GMail) account to the device, with account data sync disabled."
)
public void addAccount(String username, String password)
        throws AccountSnippetException, AccountsException, IOException {
    // Check for existing account. If we try to re-add an existing account, Android throws an
    // exception that says "Account does not exist or not visible. Maybe change pwd?" which is
    // a little hard to understand.
    if (listAccounts().contains(username)) {
        throw new AccountSnippetException(
                "Account " + username + " already exists on the device");
    }
    Bundle addAccountOptions = new Bundle();
    addAccountOptions.putString("username", username);
    addAccountOptions.putString("password", password);
    AccountManagerFuture<Bundle> future =
            mAccountManager.addAccount(
                    GOOGLE_ACCOUNT_TYPE,
                    AUTH_TOKEN_TYPE,
                    null /* requiredFeatures */,
                    addAccountOptions,
                    null /* activity */,
                    null /* authCallback */,
                    null /* handler */);
    Bundle result = future.getResult();
    if (result.containsKey(AccountManager.KEY_ERROR_CODE)) {
        throw new AccountSnippetException(
                String.format(
                        Locale.US,
                        "Failed to add account due to code %d: %s",
                        result.getInt(AccountManager.KEY_ERROR_CODE),
                        result.getString(AccountManager.KEY_ERROR_MESSAGE)));
    }

    // Disable sync to avoid test flakiness as accounts fetch additional data.
    // It takes a while for all sync adapters to be populated, so register for broadcasts when
    // sync is starting and disable them there.
    // NOTE: this listener is NOT unregistered because several sync requests for the new account
    // will come in over time.
    Account account = new Account(username, GOOGLE_ACCOUNT_TYPE);
    Object handle =
            ContentResolver.addStatusChangeListener(
                    ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE
                            | ContentResolver.SYNC_OBSERVER_TYPE_PENDING,
                    which -> {
                        for (SyncAdapterType adapter : ContentResolver.getSyncAdapterTypes()) {
                            // Ignore non-Google account types.
                            if (!adapter.accountType.equals(GOOGLE_ACCOUNT_TYPE)) {
                                continue;
                            }
                            // If a content provider is not whitelisted, then disable it.
                            // Because startSync and stopSync synchronously update the whitelist
                            // and sync settings, writelock both the whitelist check and the
                            // call to sync together.
                            mLock.writeLock().lock();
                            try {
                                if (!isAdapterWhitelisted(username, adapter.authority)) {
                                    updateSync(account, adapter.authority, false /* sync */);
                                }
                            } finally {
                                mLock.writeLock().unlock();
                            }
                        }
                    });
    mSyncStatusObserverHandles.add(handle);
}
 
Example 15
Project: BuddyBook   File: SearchResultFragment.java   View Source Code Vote up 4 votes
@Override
public Loader<List<Book>> onCreateLoader(int id, Bundle args) {

    if (mContext != null && args != null && args.containsKey(ARG_QUERY)) {

        mQuery = args.getString(ARG_QUERY);

        setLoading(true);

        if (args.containsKey(ARG_MAX_RESULT)) {

            return new SearchTask(mContext,
                    mQuery,
                    args.getInt(ARG_MAX_RESULT));

        } else {

            return new SearchTask(mContext,
                    mQuery,
                    null);
        }

    }

    return new SearchTask(mContext);
}
 
Example 16
Project: SystemUITuner2   File: IabHelper.java   View Source Code Vote up 4 votes
@SuppressWarnings("WeakerAccess")
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    // Split the sku list in blocks of no more than 20 elements.
    ArrayList<ArrayList<String>> packs = new ArrayList<>();
    ArrayList<String> tempList;
    int n = skuList.size() / 20;
    int mod = skuList.size() % 20;
    for (int i = 0; i < n; i++) {
        tempList = new ArrayList<>();
        tempList.addAll(skuList.subList(i * 20, i * 20 + 20));
        packs.add(tempList);
    }
    if (mod != 0) {
        tempList = new ArrayList<>();
        tempList.addAll(skuList.subList(n * 20, n * 20 + mod));
        packs.add(tempList);
    }

    for (ArrayList<String> skuPartList : packs) {
        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuPartList);
        Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(),
                itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                logDebug("getSkuDetails() failed: " + getResponseDesc(response));
                return response;
            } else {
                logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return IABHELPER_BAD_RESPONSE;
            }
        }

        ArrayList<String> responseList = skuDetails.getStringArrayList(
                RESPONSE_GET_SKU_DETAILS_LIST);

        for (String thisResponse : responseList != null ? responseList : new ArrayList<String>()) {
            SkuDetails d = new SkuDetails(itemType, thisResponse);
            logDebug("Got sku details: " + d);
            inv.addSkuDetails(d);
        }
    }

    return BILLING_RESPONSE_RESULT_OK;
}
 
Example 17
Project: android-state   File: InjectionHelper.java   View Source Code Vote up 4 votes
public Boolean getBoxedBoolean(Bundle state, String key) {
    if (state.containsKey(key + mBaseKey)) {
        return state.getBoolean(key + mBaseKey);
    }
    return null;
}
 
Example 18
Project: GravityBox   File: GravityBoxSettings.java   View Source Code Vote up 4 votes
public SystemProperties(Bundle data) {
            if (data.containsKey("hasGeminiSupport")) {
                hasGeminiSupport = data.getBoolean("hasGeminiSupport");
            }
            if (data.containsKey("isTablet")) {
                isTablet = data.getBoolean("isTablet");
            }
            if (data.containsKey("hasNavigationBar")) {
//                hasNavigationBar = data.getBoolean("hasNavigationBar");
                hasNavigationBar = true;
            }
            if (data.containsKey("unplugTurnsOnScreen")) {
                unplugTurnsOnScreen = data.getBoolean("unplugTurnsOnScreen");
            }
            if (data.containsKey("defaultNotificationLedOff")) {
                defaultNotificationLedOff = data.getInt("defaultNotificationLedOff");
            }
            if (data.containsKey("uuidRegistered")) {
                uuidRegistered = data.getBoolean("uuidRegistered");
            }
            if (data.containsKey("uuidType")) {
                uuidType = data.getString("uuidType");
            }
            if (data.containsKey("uncTrialCountdown")) {
                uncTrialCountdown = data.getInt("uncTrialCountdown");
            }
            if (data.containsKey("hasMsimSupport")) {
                hasMsimSupport = data.getBoolean("hasMsimSupport");
            }
            if (data.containsKey("xposedBridgeVersion")) {
                xposedBridgeVersion = data.getInt("xposedBridgeVersion");
            }
            if (data.containsKey("supportsFingerprint")) {
                supportsFingerprint = data.getBoolean("supportsFingerprint");
            }
            if (data.containsKey("fingerprintIds")) {
                fingerprintIds = data.getIntArray("fingerprintIds");
            }
            if (data.containsKey("isOxygenOs35Rom")) {
                isOxygenOs35Rom = data.getBoolean("isOxygenOs35Rom");
            }
        }
 
Example 19
Project: exchange-rates-mvvm   File: BaseActivity.java   View Source Code Vote up 4 votes
protected boolean isRetained(final Bundle state) {
    return state != null && state.containsKey(KEY_IS_RETAINED) && state.getBoolean(KEY_IS_RETAINED);
}
 
Example 20
Project: iosched-reader   File: AndroidAuthenticator.java   View Source Code Vote up 3 votes
@SuppressWarnings("deprecation")
@Override
public String getAuthToken() throws AuthFailureError {
    final AccountManager accountManager = AccountManager.get(mContext);
    AccountManagerFuture<Bundle> future = accountManager.getAuthToken(mAccount,
            mAuthTokenType, mNotifyAuthFailure, null, null);
    Bundle result;
    try {
        result = future.getResult();
    } catch (Exception e) {
        throw new AuthFailureError("Error while retrieving auth token", e);
    }
    String authToken = null;
    if (future.isDone() && !future.isCancelled()) {
        if (result.containsKey(AccountManager.KEY_INTENT)) {
            Intent intent = result.getParcelable(AccountManager.KEY_INTENT);
            throw new AuthFailureError(intent);
        }
        authToken = result.getString(AccountManager.KEY_AUTHTOKEN);
    }
    if (authToken == null) {
        throw new AuthFailureError("Got null auth token for type: " + mAuthTokenType);
    }

    return authToken;
}