android.os.Bundle#containsKey ( )源码实例Demo

下面列出了android.os.Bundle#containsKey ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: HomeGenie-Android   文件: VoiceControl.java
@Override
    public void onResults(Bundle results) {
        if ((results != null)
                && results.containsKey(SpeechRecognizer.RESULTS_RECOGNITION)) {
            List<String> heard =
                    results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
            float[] scores =
                    results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES);
            String msg = "";
            for (String s : heard) {
                Toast.makeText(_hgcontext.getApplicationContext(), "Executing: " + s, Toast.LENGTH_LONG).show();
                interpretInput(s);
//                msg += s;
                break;
            }
        }
    }
 
源代码2 项目: CSipSimple   文件: Filter.java
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;
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_listview, container, false);

    Activity parentActivity = getActivity();
    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    UiTestUtils.setDummyDataWithHeader(getActivity(), listView, inflater.inflate(R.layout.padding, null));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified position after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
            final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
            ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() {
                @Override
                public void run() {
                    // scrollTo() doesn't work, should use setSelection()
                    listView.setSelection(initialPosition);
                }
            });
        }
        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
源代码4 项目: edslite   文件: LocationListBaseFragment.java
private void restoreSelection(Bundle state)
{
    if(state.containsKey(LocationsManager.PARAM_LOCATION_URIS))
    {
        try
        {
            ArrayList<Location> selectedLocations = LocationsManager.getLocationsManager(getActivity()).getLocationsFromBundle(state);
            for(Location loc: selectedLocations)
                for(int i=0;i<_locationsList.getCount();i++)
                {
                    LocationInfo li = _locationsList.getItem(i);
                    if(li!= null && li.location.getLocationUri().equals(loc.getLocationUri()))
                        li.isSelected = true;
                }
        }
        catch (Exception e)
        {
            Logger.showAndLog(getActivity(), e);
        }

    }
}
 
源代码5 项目: Puff-Android   文件: IntroActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (fullscreen && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setSystemUiFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, true);
        setFullscreenFlags(fullscreen);
    }

    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM)) {
        position = savedInstanceState.getInt(KEY_CURRENT_ITEM, position);
    }

    setContentView(R.layout.activity_intro);
    findViews();
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mBlurEngine = new BlurDialogEngine(getActivity());
    mBlurEngine.debug(mDebugEnable);

    Bundle args = getArguments();
    if (args != null) {
        if (args.containsKey(BUNDLE_KEY_BLUR_RADIUS)) {
            mBlurEngine.setBlurRadius(args.getInt(BUNDLE_KEY_BLUR_RADIUS));
        }
        if (args.containsKey(BUNDLE_KEY_DOWN_SCALE_FACTOR)) {
            mBlurEngine.setDownScaleFactor(args.getFloat(BUNDLE_KEY_DOWN_SCALE_FACTOR));
        }
    }
}
 
源代码7 项目: android_maplibui   文件: LayerFillService.java
LocalTMSFillTask(Bundle bundle) {
    super(bundle);
    mLayer = new LocalTMSLayerUI(mLayerGroup.getContext(), mLayerPath);
    mIsNgrc = !bundle.containsKey(KEY_TMS_TYPE);
    ((LocalTMSLayerUI) mLayer).setCacheSizeMultiply(bundle.getInt(KEY_TMS_CACHE));

    if (!mIsNgrc) { // it's zip
        ((LocalTMSLayerUI) mLayer).setTMSType(bundle.getInt(KEY_TMS_TYPE));
        initLayer();
    } else
        mLayerName = mUri.getLastPathSegment();
}
 
源代码8 项目: android-open-project-demo   文件: ListFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        mContent = savedInstanceState.getString(KEY_CONTENT);
    }
}
 
源代码9 项目: AndroidDemoProjects   文件: MainActivity.java
@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
if( savedInstanceState != null ) {
	if( savedInstanceState.containsKey( EXTRA_LAT ) && savedInstanceState.containsKey( EXTRA_LONG ) ) {
		mCurrentLocation = new LatLng( savedInstanceState.getDouble( EXTRA_LAT ), savedInstanceState.getDouble( EXTRA_LONG ) );
		if( savedInstanceState.containsKey( EXTRA_TILT ) && savedInstanceState.containsKey( EXTRA_BEARING ) ) {
			mTilt = savedInstanceState.getFloat( EXTRA_TILT );
			mBearing = savedInstanceState.getFloat( EXTRA_BEARING );
			mZoom = savedInstanceState.getFloat( EXTRA_ZOOM );
		}
	}
}
  }
 
源代码10 项目: KUAS-AP-Material   文件: BusActivity.java
private void restoreArgs(Bundle savedInstanceState) {
	if (savedInstanceState != null) {
		mDate = savedInstanceState.getString("mDate");
		mIndex = savedInstanceState.getInt("mIndex");
		mInitListPos = savedInstanceState.getInt("mInitListPos");
		mInitListOffset = savedInstanceState.getInt("mInitListOffset");
		isRetry = savedInstanceState.getBoolean("isRetry");

		if (savedInstanceState.containsKey("mJianGongList")) {
			mJianGongList = new Gson().fromJson(savedInstanceState.getString("mJianGongList"),
					new TypeToken<List<BusModel>>() {

					}.getType());
		}
		if (savedInstanceState.containsKey("mYanChaoList")) {
			mYanChaoList = new Gson().fromJson(savedInstanceState.getString("mYanChaoList"),
					new TypeToken<List<BusModel>>() {

					}.getType());
		}
	} else {
		showDatePickerDialog();
	}

	if (mJianGongList == null) {
		mJianGongList = new ArrayList<>();
	}
	if (mYanChaoList == null) {
		mYanChaoList = new ArrayList<>();
	}
}
 
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    if (savedInstanceState != null && savedInstanceState.containsKey(BUNDLE_RESULT)) {
        // Store data as pending result for display after activity has resumed.
        mPendingResult = savedInstanceState.getString(BUNDLE_RESULT);
    }
}
 
源代码12 项目: imsdk-android   文件: PictureSelectorActivity.java
protected void injectExtras() {
    Bundle extras_ = getIntent().getExtras();
    if (extras_ != null) {
        if (extras_.containsKey("isMultiSel")) {
            isMultiSel = extras_.getBoolean("isMultiSel");
        }
        if (extras_.containsKey("isGravantarSel")) {
            isGravantarSel = extras_.getBoolean("isGravantarSel");
        }
        if (extras_.containsKey(SHOW_EDITOR)) {
            showEditor = extras_.getBoolean(SHOW_EDITOR);
        }
    }
}
 
源代码13 项目: smartcoins-wallet   文件: SendScreen.java
private void startupTasks() {
    runningSpinerForFirstTime = true;
    init();
    Intent intent = getIntent();
    Bundle res = intent.getExtras();
    if (res != null) {
        if (res.containsKey("sResult") && res.containsKey("id")) {
            if (res.getInt("id") == 5) {
                try {
                    decodeInvoiceData(res.getString("sResult"));
                } catch (Exception e) {
                    Log.e(TAG, "Unable to Decode QR. Exception Msg: " + e.getMessage());
                    Toast.makeText(SendScreen.this, SendScreen.this.getResources().getString(R.string.unable_to_decode_QR), Toast.LENGTH_SHORT).show();
                }

            }
        }
    }

    String basset = etBackupAsset.getText().toString();

    if (!basset.isEmpty()) {
        backupAssetCHanged(basset);
    }

    loadWebView(webviewTo, 39, Helper.hash("", Helper.SHA256));
}
 
源代码14 项目: braintree_android   文件: AppSwitchHelper.java
public static Result parseAppSwitchResponse(ContextInspector contextInspector, Request request, Intent data) {
    Bundle bundle = data.getExtras();
    if (request.validateV1V2Response(bundle)) {
        request.trackFpti(contextInspector.getContext(), TrackingPoint.Return, null);
        return processResponseIntent(bundle);
    } else {
        if (bundle.containsKey("error")) {
            request.trackFpti(contextInspector.getContext(), TrackingPoint.Error, null);
            return new Result(new WalletSwitchException(bundle.getString("error")));
        } else {
            request.trackFpti(contextInspector.getContext(), TrackingPoint.Error, null);
            return new Result(new ResponseParsingException("invalid wallet response"));
        }
    }
}
 
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_listview, container, false);

    Activity parentActivity = getActivity();
    final ObservableListView listView = (ObservableListView) view.findViewById(R.id.scroll);
    setDummyDataWithHeader(listView, inflater.inflate(R.layout.padding, listView, false));

    if (parentActivity instanceof ObservableScrollViewCallbacks) {
        // Scroll to the specified position after layout
        Bundle args = getArguments();
        if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
            final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
            ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() {
                @Override
                public void run() {
                    // scrollTo() doesn't work, should use setSelection()
                    listView.setSelection(initialPosition);
                }
            });
        }

        // TouchInterceptionViewGroup should be a parent view other than ViewPager.
        // This is a workaround for the issue #117:
        // https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
        listView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));

        listView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
    }
    return view;
}
 
源代码16 项目: AndroidBottomSheet   文件: BottomSheet.java
@Override
public final void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
    setTitle(savedInstanceState.getCharSequence(TITLE_EXTRA));
    setTitleColor(savedInstanceState.getInt(TITLE_COLOR_EXTRA));
    setCancelable(savedInstanceState.getBoolean(CANCELABLE_EXTRA));
    setCanceledOnTouchOutside(savedInstanceState.getBoolean(CANCELED_ON_TOUCH_OUTSIDE_EXTRA));
    setDragSensitivity(savedInstanceState.getFloat(DRAG_SENSITIVITY_EXTRA));
    setDimAmount(savedInstanceState.getFloat(DIM_AMOUNT_EXTRA));
    setWidth(savedInstanceState.getInt(WIDTH_EXTRA));

    if (savedInstanceState.containsKey(ICON_BITMAP_EXTRA)) {
        setIcon((Bitmap) savedInstanceState.getParcelable(ICON_BITMAP_EXTRA));
    } else if (savedInstanceState.containsKey(ICON_ID_EXTRA)) {
        setIcon(savedInstanceState.getInt(ICON_ID_EXTRA));
    } else if (savedInstanceState.containsKey(ICON_ATTRIBUTE_ID_EXTRA)) {
        setIconAttribute(savedInstanceState.getInt(ICON_ATTRIBUTE_ID_EXTRA));
    }

    if (savedInstanceState.containsKey(BACKGROUND_BITMAP_EXTRA)) {
        setBackground((Bitmap) savedInstanceState.getParcelable(BACKGROUND_BITMAP_EXTRA));
    } else if (savedInstanceState.containsKey(BACKGROUND_ID_EXTRA)) {
        setBackground(savedInstanceState.getInt(BACKGROUND_ID_EXTRA));
    } else if (savedInstanceState.containsKey(BACKGROUND_COLOR_EXTRA)) {
        setBackgroundColor(savedInstanceState.getInt(BACKGROUND_COLOR_EXTRA));
    }

    super.onRestoreInstanceState(savedInstanceState);
}
 
源代码17 项目: cordova-plugin-wizpurchase   文件: IabHelper.java
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
                             throws RemoteException, JSONException {
     logDebug("Querying SKU details.");
     ArrayList<String> skuList = new ArrayList<String>();
     skuList.addAll(inv.getAllOwnedSkus(itemType));
     if (moreSkus != null) {
logDebug("moreSkus: Building SKUs List");
         for (String sku : moreSkus) {
	logDebug("moreSkus: "+sku);
             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;
     }

     Bundle querySkus = new Bundle();
     querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
     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) {
         SkuDetails d = new SkuDetails(itemType, thisResponse);
         logDebug("Got sku details: " + d);
         inv.addSkuDetails(d);
     }
     return BILLING_RESPONSE_RESULT_OK;
 }
 
源代码18 项目: ScreenShift   文件: IabHelper.java
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
                            throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    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;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    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) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}
 
源代码19 项目: EasyVPN-Free   文件: IabHelper.java
int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
                            throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    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;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    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) {
        SkuDetails d = new SkuDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}
 
源代码20 项目: Cashier   文件: InAppBillingV3Vendor.java
private List<InAppBillingPurchase> getPurchases(String type)
    throws RemoteException, ApiException, JSONException {
  throwIfUninitialized();
  if (type.equals(PRODUCT_TYPE_ITEM)) {
    log("Querying item purchases...");
  } else {
    log("Querying subscription purchases...");
  }
  String paginationToken = null;
  final List<InAppBillingPurchase> purchaseList = new ArrayList<>();
  do {
    final Bundle purchases = api.getPurchases(type, paginationToken);

    final int response = getResponseCode(purchases);
    log("Got response: " + response);
    if (response != BILLING_RESPONSE_RESULT_OK) {
      throw new ApiException(response);
    }

    if (!purchases.containsKey(RESPONSE_INAPP_ITEM_LIST)
        || !purchases.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
        || !purchases.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
      throw new ApiException(BILLING_RESPONSE_RESULT_ERROR);
    }

    final List<String> purchasedSkus
        = purchases.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
    final List<String> purchaseDataList
        = purchases.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
    final List<String> signatureList
        = purchases.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

    if (purchasedSkus == null || purchaseDataList == null || signatureList == null) {
      return Collections.emptyList();
    }

    final List<Product> purchasedProducts = getProductsWithType(purchasedSkus, type);

    for (int i = 0; i < purchaseDataList.size(); ++i) {
      final String purchaseData = purchaseDataList.get(i);
      final String sku = purchasedSkus.get(i);
      final String signature = signatureList.get(i);

      Product product = null;
      for (final Product maybeProduct : purchasedProducts) {
        if (sku.equals(maybeProduct.sku())) {
          product = maybeProduct;
          break;
        }
      }

      if (product == null) {
        // TODO: Should raise this as an error to the user
        continue;
      }

      log("Found purchase: " + sku);
      if (!TextUtils.isEmpty(publicKey64)) {
        if (InAppBillingSecurity.verifySignature(publicKey64, purchaseData, signature)) {
          log("Purchase locally verified: " + sku);
        } else {
          log("Purchase not locally verified: " + sku);
          continue;
        }
      }

      purchaseList.add(InAppBillingPurchase.create(product, purchaseData, signature));
    }

    paginationToken = purchases.getString(INAPP_CONTINUATION_TOKEN);
    if (paginationToken != null) {
      log("Pagination token found, continuing on....");
    }
  } while (!TextUtils.isEmpty(paginationToken));

  return Collections.unmodifiableList(purchaseList);
}