本文整理汇总了Java中android.os.Bundle.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.containsKey方法的具体用法?Java Bundle.containsKey怎么用?Java Bundle.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.containsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbsAttachmentsEditPresenter
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
}
示例2: onRestoreInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例3: patternMatches
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例4: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
});
}
示例5: onResume
import android.os.Bundle; //导入方法依赖的package包/类
/**
* 當接收到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();
}
示例6: updateCallOptions
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例7: onActivityResult
import android.os.Bundle; //导入方法依赖的package包/类
@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;
}
}
示例8: onStartCommand
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例9: getBundleData
import android.os.Bundle; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例10: onViewCreated
import android.os.Bundle; //导入方法依赖的package包/类
@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));
}
}
示例11: onViewCreated
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例12: getBoxedChar
import android.os.Bundle; //导入方法依赖的package包/类
public Character getBoxedChar(Bundle state, String key) {
if (state.containsKey(key + baseKey)) {
return state.getChar(key + baseKey);
}
return null;
}
示例13: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@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();
}
});
}
示例14: Google
import android.os.Bundle; //导入方法依赖的package包/类
/**
* 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);
}
示例15: onCreateLoader
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}