Example usage for android.os Bundle getInt

List of usage examples for android.os Bundle getInt

Introduction

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

Prototype

public int getInt(String key) 

Source Link

Document

Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.

Usage

From source file:com.firefly.sample.castcompanionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by
 * <code>fromMediaInfo</code>.
 *
 * @see <code>fromMediaInfo()</code>
 * @param wrapper//ww  w.  j a  va  2 s .  c  om
 * @return
 */
public static MediaInfo toMediaInfo(Bundle wrapper) {
    if (null == wrapper) {
        return null;
    }

    MediaMetadata metaData = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);

    metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE));
    metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE));
    metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO));
    ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES);
    if (null != images && !images.isEmpty()) {
        for (String url : images) {
            Uri uri = Uri.parse(url);
            metaData.addImage(new WebImage(uri));
        }
    }
    String customDataStr = wrapper.getString(KEY_CUSTOM_DATA);
    JSONObject customData = null;
    if (!TextUtils.isEmpty(customDataStr)) {
        try {
            customData = new JSONObject(customDataStr);
        } catch (JSONException e) {
            LOGE(TAG, "Failed to deserialize the custom data string: custom data= " + customDataStr);
        }
    }
    return new MediaInfo.Builder(wrapper.getString(KEY_URL)).setStreamType(wrapper.getInt(KEY_STREAM_TYPE))
            .setContentType(wrapper.getString(KEY_CONTENT_TYPE)).setMetadata(metaData).setCustomData(customData)
            .build();
}

From source file:animade.ataner.GaleriaDetal.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.galeria_detal);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        gal_id = extras.getInt("galeria_id");
    }//w  w w . j  av  a  2s  . c  om

    JSONArray aListImage = Ataner.aListImage.get(gal_id);
    String[] imageUrls = new String[aListImage.length()];

    for (int i = 0; i < aListImage.length(); i++) {
        try {
            JSONObject rec = aListImage.getJSONObject(i);
            imageUrls[i] = rec.getString("image");
        } catch (JSONException e1) {
            e1.printStackTrace();
        }
    }

    options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_empty)
            .showImageOnFail(R.drawable.ic_error).resetViewBeforeLoading().cacheOnDisc()
            .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    pager = (ViewPagerCustomDuration) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(imageUrls));
    pager.setCurrentItem(0);
    //pager.setPageTransformer(true, new ZoomOutPageTransformer());
}

From source file:com.nextgis.mobile.map.MapBase.java

/**
 * Process message received by handler/*from w  w  w . j a  v a2  s . com*/
 *
 * @param bundle A message payload
 */
protected void processMessage(Bundle bundle) {
    switch (bundle.getInt(BUNDLE_TYPE_KEY)) {
    case MSGTYPE_DRAWING_DONE:
        onLayerDrawFinished(bundle.getFloat(BUNDLE_DONE_KEY));
        break;
    default:
        break;
    }
}

From source file:com.thunder.iap.IAPActivity.java

/**
 *
 * @param skuList the list of available skus
 * @param listener/*w ww  .ja va 2 s.  co  m*/
 */
public void getSkuDetails(final ArrayList<String> skuList, final SkuDetailsListener listener) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            Bundle querySkus = new Bundle();
            querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
            try {
                Bundle skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus);
                ArrayList<JSONObject> result = new ArrayList<JSONObject>();
                int response = skuDetails.getInt("RESPONSE_CODE");
                if (response == 0) {
                    ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
                    for (String thisResponse : responseList) {
                        JSONObject object = null;
                        try {
                            object = new JSONObject(thisResponse);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        //String sku = object.getString("productId");
                        //String price = object.getString("price");
                        //if (sku.equals("premiumUpgrade")) mPremiumUpgradePrice = price;
                        //else if (sku.equals("gas")) mGasPrice = price;
                        result.add(object);
                    }
                    listener.onResult(result);
                } else {
                    listener.onServerError(skuDetails);
                }
            } catch (RemoteException e) {
                e.printStackTrace();
                listener.onError(e);
            }
        }
    }).start();
}

From source file:fr.cph.chicago.activity.BusActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    mBusStopId = savedInstanceState.getInt("busStopId");
    mBusRouteId = savedInstanceState.getString("busRouteId");
    mBound = savedInstanceState.getString("bound");
    mBusStopName = savedInstanceState.getString("busStopName");
    mBusRouteName = savedInstanceState.getString("busRouteName");
    mLatitude = savedInstanceState.getDouble("latitude");
    mLongitude = savedInstanceState.getDouble("longitude");
}

From source file:me.henrytao.bootstrapandroidlibrarydemo.activity.BaseActivity.java

private void requestItemsForPurchase(final AsyncCallback<List<PurchaseItem>> callback) {
    if (mPurchaseItems != null && mPurchaseItems.size() > 0) {
        if (callback != null) {
            callback.onSuccess(mPurchaseItems);
        }/*from  w w  w.j  av a  2  s.c o m*/
        return;
    }
    new AsyncTask<IInAppBillingService, Void, AsyncResult<List<PurchaseItem>>>() {

        @Override
        protected AsyncResult<List<PurchaseItem>> doInBackground(IInAppBillingService... params) {
            List<PurchaseItem> result = new ArrayList<>();
            Throwable exception = null;
            IInAppBillingService billingService = params[0];

            if (billingService == null) {
                exception = new Exception("Unknow");
            } else {
                ArrayList<String> skuList = new ArrayList<>(Arrays.asList(mDonateItems));
                Bundle querySkus = new Bundle();
                querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
                try {
                    Bundle skuDetails = billingService.getSkuDetails(3, getPackageName(), "inapp", querySkus);
                    int response = skuDetails.getInt("RESPONSE_CODE");
                    if (response == 0) {
                        ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
                        PurchaseItem purchaseItem;
                        for (String item : responseList) {
                            purchaseItem = new PurchaseItem(new JSONObject(item));
                            if (purchaseItem.isValid()) {
                                result.add(purchaseItem);
                            }
                        }
                    }
                } catch (RemoteException e) {
                    e.printStackTrace();
                    exception = e;
                } catch (JSONException e) {
                    e.printStackTrace();
                    exception = e;
                }
            }
            return new AsyncResult<>(result, exception);
        }

        @Override
        protected void onPostExecute(AsyncResult<List<PurchaseItem>> result) {
            if (!isFinishing() && callback != null) {
                Throwable error = result.getError();
                if (error == null && (result.getResult() == null || result.getResult().size() == 0)) {
                    error = new Exception("Unknow");
                }
                if (error != null) {
                    callback.onError(error);
                } else {
                    mPurchaseItems = result.getResult();
                    Collections.sort(mPurchaseItems, new Comparator<PurchaseItem>() {
                        @Override
                        public int compare(PurchaseItem lhs, PurchaseItem rhs) {
                            return (int) ((lhs.getPriceAmountMicros() - rhs.getPriceAmountMicros()) / 1000);
                        }
                    });
                    callback.onSuccess(mPurchaseItems);
                }
            }
        }
    }.execute(mBillingService);
}

From source file:com.google.android.apps.dashclock.ExtensionManager.java

/**
 * Returns a listing of all available (installed) extensions, including those that aren't
 * world-readable.//from   w ww . j  a v a  2s  .c o  m
 */
public List<ExtensionListing> getAvailableExtensions() {
    List<ExtensionListing> availableExtensions = new ArrayList<>();
    PackageManager pm = mApplicationContext.getPackageManager();
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(DashClockExtension.ACTION_EXTENSION),
            PackageManager.GET_META_DATA);
    for (ResolveInfo resolveInfo : resolveInfos) {
        ExtensionListing info = new ExtensionListing();
        info.componentName(
                new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name));
        info.title(resolveInfo.loadLabel(pm).toString());
        Bundle metaData = resolveInfo.serviceInfo.metaData;
        if (metaData != null) {
            info.compatible(ExtensionHost.supportsProtocolVersion(metaData.getInt("protocolVersion")));
            info.worldReadable(metaData.getBoolean("worldReadable", false));
            info.description(metaData.getString("description"));
            String settingsActivity = metaData.getString("settingsActivity");
            if (!TextUtils.isEmpty(settingsActivity)) {
                info.settingsActivity(ComponentName
                        .unflattenFromString(resolveInfo.serviceInfo.packageName + "/" + settingsActivity));
            }
        }

        info.icon(resolveInfo.getIconResource());
        availableExtensions.add(info);
    }

    return availableExtensions;
}

From source file:com.envyserve.githubreference.billing.BillingProcessor.java

private List<SkuDetails> getSkuDetails(ArrayList<String> productIdList, String purchaseType) {
    if (billingService != null && productIdList != null && productIdList.size() > 0) {
        try {/*from w ww. ja  v a  2 s .com*/
            Bundle products = new Bundle();
            products.putStringArrayList(Constants.PRODUCTS_LIST, productIdList);
            Bundle skuDetails = billingService.getSkuDetails(Constants.GOOGLE_API_VERSION, contextPackageName,
                    purchaseType, products);
            int response = skuDetails.getInt(Constants.RESPONSE_CODE);

            if (response == Constants.BILLING_RESPONSE_RESULT_OK) {
                ArrayList<SkuDetails> productDetails = new ArrayList<SkuDetails>();

                for (String responseLine : skuDetails.getStringArrayList(Constants.DETAILS_LIST)) {
                    JSONObject object = new JSONObject(responseLine);
                    SkuDetails product = new SkuDetails(object);
                    productDetails.add(product);
                }
                return productDetails;

            } else {
                if (eventHandler != null)
                    eventHandler.onBillingError(response, null);
                Log.e(LOG_TAG, String.format("Failed to retrieve info for %d products, %d",
                        productIdList.size(), response));
            }
        } catch (Exception e) {
            Log.e(LOG_TAG, String.format("Failed to call getSkuDetails %s", e.toString()));
        }
    }
    return null;
}

From source file:com.google.android.apps.dashclock.api.ExtensionData.java

/**
 * Deserializes the given {@link Bundle} representation of extension data, populating this
 * object./*from  ww w.  jav  a  2  s  .c  o  m*/
 */
public void fromBundle(Bundle src) {
    this.mVisible = src.getBoolean(KEY_VISIBLE, true);
    this.mIcon = src.getInt(KEY_ICON);
    String iconUriString = src.getString(KEY_ICON_URI);
    this.mIconUri = TextUtils.isEmpty(iconUriString) ? null : Uri.parse(iconUriString);
    this.mStatus = src.getString(KEY_STATUS);
    this.mExpandedTitle = src.getString(KEY_EXPANDED_TITLE);
    this.mExpandedBody = src.getString(KEY_EXPANDED_BODY);
    try {
        this.mClickIntent = Intent.parseUri(src.getString(KEY_CLICK_INTENT), 0);
    } catch (URISyntaxException ignored) {
    }
    this.mContentDescription = src.getString(KEY_CONTENT_DESCRIPTION);
}

From source file:com.kuaichumen.whistle.admin.CaptureActivity.java

private void InitData() {
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        type = bundle.getInt("type");
        if (type == 0) {
            title.setText("?");
        } else {//from   ww w .  j  av a 2 s.  com
            title.setText("??");
        }
    }
    ksHttpRequestCollection.setRequestFinishListener(new KSHttpRequestCollection.RequestFinishListener() {
        @Override
        public void onSuccess(HttpRequestResult httpRequestResult) {
            try {
                dismissLoadingDialog();
                JSONObject jsonObject = new JSONObject(httpRequestResult.getResult());
                LogUtil.d(TAG, jsonObject.toString());
                int resultcode = jsonObject.getJSONObject("error").getInt("errorno");
                Intent intent = null;
                switch (resultcode) {
                case 0:
                    result = jsonObject.getString("result");
                    switch (httpRequestResult.getRequestType()) {
                    case KSHttpRequestCollection.activitySigninURL://?
                        ToSigninResultActivity(SUCCESS, result);
                        break;
                    case KSHttpRequestCollection.welfareVerifyURL://???
                        //?
                        ToBenefitsGrantResultActivity(SUCCESS, result);
                        break;
                    }
                    break;
                case 323:
                    result = jsonObject.getString("result");
                    ToSigninResultActivity(FAIL, result);
                    break;
                case 331://?
                    result = jsonObject.getString("result");
                    ToBenefitsGrantResultActivity(FAIL, result);
                    break;
                case 330:
                    showMessage(ksHttpRequestCollection.requestResultCodeMap.get(resultcode));
                    break;
                case 321:
                    showMessage(ksHttpRequestCollection.requestResultCodeMap.get(resultcode));
                    break;
                default:
                    showMessage(ksHttpRequestCollection.requestResultCodeMap.get(resultcode));
                    finish();
                    break;
                }
            } catch (Exception e) {

            }

        }

        @Override
        public void onFailure(HttpRequestResult httpRequestResult) {
            if (type == 1) {
                showMessage("???");
            } else {
                showMessage("??");
            }
            LogUtil.d(TAG, httpRequestResult.getResult());
            dismissLoadingDialog();
        }
    });
}