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.lepin.activity.PincheTrailActivity.java

/**
 * ?/*from ww  w  .j a v  a2 s  .co  m*/
 */
private void initView() {
    final Bundle bundle = getIntent().getExtras();
    pinche_id = bundle.getInt("PincheId");
    this.mTitleBack.setOnClickListener(this);
    this.mPhotoView.setOnClickListener(this);
    this.mapImageView.setOnClickListener(this);
    this.mTitle.setText(getResources().getString(R.string.pick_trail_Title));// ?title
}

From source file:com.nononsenseapps.filepicker.sample.ftp.FtpPickerFragment.java

@Override
public void onCreate(Bundle b) {
    super.onCreate(b);

    Bundle args = getArguments();
    this.server = args.getString(KEY_FTP_SERVER);
    this.port = args.getInt(KEY_FTP_PORT);
    this.username = args.getString(KEY_FTP_USERNAME) != null ? args.getString(KEY_FTP_USERNAME) : "anonymous";
    this.password = args.getString(KEY_FTP_PASSWORD) != null ? args.getString(KEY_FTP_PASSWORD) : "anonymous";
    this.rootDir = args.getString(KEY_FTP_ROOTDIR) != null ? args.getString(KEY_FTP_ROOTDIR) : "/";
}

From source file:com.gamethrive.TrackGooglePurchase.java

private void sendPurchases(final ArrayList<String> skusToAdd, final ArrayList<String> newPurchaseTokens) {
    try {/* ww w .  j  a  va2  s .  c  o  m*/
        if (getSkuDetailsMethod == null)
            getSkuDetailsMethod = IInAppBillingServiceClass.getMethod("getSkuDetails", int.class, String.class,
                    String.class, Bundle.class);

        Bundle querySkus = new Bundle();
        querySkus.putStringArrayList("ITEM_ID_LIST", skusToAdd);
        Bundle skuDetails = (Bundle) getSkuDetailsMethod.invoke(mIInAppBillingService, 3,
                appContext.getPackageName(), "inapp", querySkus);

        int response = skuDetails.getInt("RESPONSE_CODE");
        if (response == 0) {
            ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST");
            Map<String, JSONObject> currentSkus = new HashMap<String, JSONObject>();
            JSONObject jsonItem;
            for (String thisResponse : responseList) {
                JSONObject object = new JSONObject(thisResponse);
                String sku = object.getString("productId");
                BigDecimal price = new BigDecimal(object.getString("price_amount_micros"));
                price = price.divide(new BigDecimal(1000000));

                jsonItem = new JSONObject();
                jsonItem.put("sku", sku);
                jsonItem.put("iso", object.getString("price_currency_code"));
                jsonItem.put("amount", price.toString());
                currentSkus.put(sku, jsonItem);
            }

            JSONArray purchasesToReport = new JSONArray();
            for (String sku : skusToAdd) {
                if (!currentSkus.containsKey(sku))
                    continue;
                purchasesToReport.put(currentSkus.get(sku));
            }

            // New purchases to report.
            // Wait until we have a playerID then send purchases to server. If successful then mark them as tracked.
            if (purchasesToReport.length() > 0) {
                final JSONArray finalPurchasesToReport = purchasesToReport;
                gameThrive.idsAvailable(new IdsAvailableHandler() {
                    public void idsAvailable(String playerId, String registrationId) {
                        gameThrive.sendPurchases(finalPurchasesToReport, newAsExisting,
                                new JsonHttpResponseHandler() {
                                    public void onFailure(int statusCode, Header[] headers, Throwable throwable,
                                            JSONObject errorResponse) {
                                        Log.i(GameThrive.TAG, "JSON sendPurchases Failed");
                                        throwable.printStackTrace();
                                        isWaitingForPurchasesRequest = false;
                                    }

                                    public void onSuccess(int statusCode, Header[] headers,
                                            JSONObject response) {
                                        purchaseTokens.addAll(newPurchaseTokens);
                                        prefsEditor.putString("purchaseTokens", purchaseTokens.toString());
                                        prefsEditor.remove("ExistingPurchases");
                                        prefsEditor.commit();
                                        newAsExisting = false;
                                        isWaitingForPurchasesRequest = false;
                                    }
                                });
                    }
                });

            }
        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

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

/**
 * returns the purchased items for a user
 * @param itemType/* ww  w .j a  va  2s. com*/
 * @param purchasedItemsListener
 */
public void getPurchasedItems(String itemType, PurchasedItemsListener purchasedItemsListener) {
    try {
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), itemType, null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0) {
            ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
            ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
            ArrayList<String> signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
            String continuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN");
            Map<String, PurchasedItem> skuToPurchasedItem = new HashMap<String, PurchasedItem>();
            for (int i = 0; i < purchaseDataList.size(); ++i) {
                String purchaseData = purchaseDataList.get(i);
                String signature = signatureList.get(i);
                String sku = ownedSkus.get(i);
                // do something with this purchase information
                // e.g. display the updated list of products owned by user
                skuToPurchasedItem.put(sku, new PurchasedItem(purchaseData, signature, sku));
            }
            while (continuationToken != null) {
                try {
                    ownedItems = mService.getPurchases(3, getPackageName(), itemType, continuationToken);
                    response = ownedItems.getInt("RESPONSE_CODE");
                    if (response == 0) {
                        ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                        purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
                        signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
                        continuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN");
                        for (int i = 0; i < purchaseDataList.size(); ++i) {
                            String purchaseData = purchaseDataList.get(i);
                            String signature = signatureList.get(i);
                            String sku = ownedSkus.get(i);
                            // do something with this purchase information
                            // e.g. display the updated list of products owned by user
                            skuToPurchasedItem.put(sku, new PurchasedItem(purchaseData, signature, sku));
                        }
                    } else {
                        purchasedItemsListener.onServerError(ownedItems);
                    }
                } catch (RemoteException e) {
                    e.printStackTrace();
                    purchasedItemsListener.onError(e);
                }
            }
            // if continuationToken != null, call getPurchases again
            // and pass in the token to retrieve more items
        } else {
            purchasedItemsListener.onServerError(ownedItems);
        }
    } catch (RemoteException e) {
        e.printStackTrace();
        purchasedItemsListener.onError(e);
    }
}

From source file:com.facebook.LegacyTokenCacheTest.java

@Test
public void testMultipleCaches() {
    Bundle bundle1 = new Bundle(), bundle2 = new Bundle();

    bundle1.putInt(INT_KEY, 10);//  w w w.j a va2  s  . c o m
    bundle1.putString(STRING_KEY, "ABC");
    bundle2.putInt(INT_KEY, 100);
    bundle2.putString(STRING_KEY, "xyz");

    ensureApplicationContext();

    LegacyTokenHelper cache1 = new LegacyTokenHelper(RuntimeEnvironment.application);
    LegacyTokenHelper cache2 = new LegacyTokenHelper(RuntimeEnvironment.application, "CustomCache");

    cache1.save(bundle1);
    cache2.save(bundle2);

    // Get new references to make sure we are getting persisted data.
    // Reverse the cache references for fun.
    cache1 = new LegacyTokenHelper(RuntimeEnvironment.application, "CustomCache");
    cache2 = new LegacyTokenHelper(RuntimeEnvironment.application);

    Bundle newBundle1 = cache1.load(), newBundle2 = cache2.load();

    assertEquals(bundle2.getInt(INT_KEY), newBundle1.getInt(INT_KEY));
    assertEquals(bundle2.getString(STRING_KEY), newBundle1.getString(STRING_KEY));
    assertEquals(bundle1.getInt(INT_KEY), newBundle2.getInt(INT_KEY));
    assertEquals(bundle1.getString(STRING_KEY), newBundle2.getString(STRING_KEY));
}

From source file:com.flat20.fingerplay.FingerPlayActivity.java

private void checkPurchases() {
    try {//from   ww w . j  a  v a2s. c  om
        Bundle ownedItems = mBillingService.getPurchases(3, getPackageName(), "subs", null);
        if (ownedItems.getInt("RESPONSE_CODE") == 0) {
            ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
            ArrayList<String> ownedData = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
            if (ownedSkus == null || ownedSkus.isEmpty()) {
                showSubscribeDialog();
            } else {
                for (int i = 0; i < ownedSkus.size(); i++) {
                    if (IAP_SUBS_KEY.equals(ownedSkus.get(i))) {
                        JSONObject jsonData = new JSONObject(ownedData.get(i));
                        int purchaseState = jsonData.getInt("purchaseState");
                        if (purchaseState == 0) {
                            Toast.makeText(this, R.string.toast_subs_verified, Toast.LENGTH_SHORT).show();
                            if (TextUtils.isEmpty(PreferenceManager.getDefaultSharedPreferences(this)
                                    .getString("settings_server_address", null))) {
                                Toast.makeText(this, R.string.toast_server_not_setup, Toast.LENGTH_SHORT)
                                        .show();
                                startActivity(new Intent(getApplicationContext(), SettingsView.class));
                            }
                        } else if (purchaseState == 1) {
                            unableToVerifyLicense(getString(R.string.billing_error_cancelled), true);
                        } else if (purchaseState == 2) {
                            unableToVerifyLicense(getString(R.string.billing_error_refunded), true);
                        } else {
                            unableToVerifyLicense(getString(R.string.billing_error_unknown_state), true);
                        }
                    }
                }
            }
        } else {
            unableToVerifyLicense(getString(R.string.billing_error_unknown), true);
        }
    } catch (Exception e) {
        Log.e("Fingerplay", "Error checking for purchases", e);
        unableToVerifyLicense(getString(R.string.billing_error_unknown), true);
    }
}

From source file:com.example.drugsformarinemammals.ViewPager_MainMenu.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewpager_mainmenu);
    helper = new Handler_Sqlite(this);
    PagerTabStrip mPagerTabStrip = (PagerTabStrip) findViewById(R.id.title);
    int size = mPagerTabStrip.getChildCount();
    for (int i = 0; i < size; i++) {
        View child = mPagerTabStrip.getChildAt(i);
        if (child instanceof TextView) {
            textView = (TextView) child;
            textView.setTypeface(Typeface.SANS_SERIF);
        }//  w w w .  jav a2s.  c om
    }

    ViewPager vpPager = (ViewPager) findViewById(R.id.vp_mainmenu);
    adapterViewPager = new MyPagerAdapter(getSupportFragmentManager());
    vpPager.setAdapter(adapterViewPager);
    Bundle extra = this.getIntent().getExtras();
    if (extra != null) {
        if (extra.getInt("dosis") == 2)
            vpPager.setCurrentItem(2);
        else
            vpPager.setCurrentItem(3);
    } else
        vpPager.setCurrentItem(1);

}

From source file:de.dmxcontrol.fragment.ActionSelectorFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mState = savedInstanceState.getInt(EXTRA_PANEL_STATE);
    }// ww  w  .j  ava  2s  .  c om
}

From source file:com.nokia.example.paymentoneapk.PaymentOneAPKActivity.java

public void launchPurchase(final String sku, final String itemType, final int requestCode,
        final String extraData) {

    Log.d(TAG, "PaymentOneAPKActivity.launchPurchase");

    try {/*from  ww  w .  ja v a 2  s.  c om*/
        final Bundle buyIntentBundle = mService.getBuyIntent(API_VERSION, getPackageName(), sku, itemType,
                extraData);

        final int response = buyIntentBundle.getInt("RESPONSE_CODE");

        if (response != PaymentOneAPKUtils.RESULT_OK) {

            Log.e(TAG, String.format("error while buying. response=%s", getErrorMessage(response)));
            toastMessage(String.format("Got an error while buying: %s", getErrorMessage(response)));

            return;
        }

        final PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

        Log.d(TAG, String.format("pendingIntent = %s", pendingIntent));

        startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(), 0, 0, 0);

    } catch (final RemoteException e) {
        Log.e(TAG, "error while buying", e);
        toastMessage("Got an exception while buying");
    } catch (final IntentSender.SendIntentException e) {
        Log.e(TAG, "error while buying", e);
        toastMessage("Got an exception while buying");
    }
}

From source file:com.onesignal.TrackGooglePurchase.java

private void QueryBoughtItems() {
    if (isWaitingForPurchasesRequest)
        return;/*from   ww w.  j  a  v a 2  s. c o m*/

    new Thread(new Runnable() {
        public void run() {
            isWaitingForPurchasesRequest = true;
            try {
                if (getPurchasesMethod == null) {
                    getPurchasesMethod = getGetPurchasesMethod(IInAppBillingServiceClass);
                    getPurchasesMethod.setAccessible(true);
                }

                Bundle ownedItems = (Bundle) getPurchasesMethod.invoke(mIInAppBillingService, 3,
                        appContext.getPackageName(), "inapp", null);
                if (ownedItems.getInt("RESPONSE_CODE") == 0) {
                    ArrayList<String> skusToAdd = new ArrayList<String>();
                    ArrayList<String> newPurchaseTokens = new ArrayList<String>();

                    ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                    ArrayList<String> purchaseDataList = ownedItems
                            .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                    for (int i = 0; i < purchaseDataList.size(); i++) {
                        String purchaseData = purchaseDataList.get(i);
                        String sku = ownedSkus.get(i);
                        JSONObject itemPurchased = new JSONObject(purchaseData);
                        String purchaseToken = itemPurchased.getString("purchaseToken");

                        if (!purchaseTokens.contains(purchaseToken)
                                && !newPurchaseTokens.contains(purchaseToken)) {
                            newPurchaseTokens.add(purchaseToken);
                            skusToAdd.add(sku);
                        }
                    }

                    if (skusToAdd.size() > 0)
                        sendPurchases(skusToAdd, newPurchaseTokens);
                    else if (purchaseDataList.size() == 0) {
                        newAsExisting = false;
                        prefsEditor.putBoolean("ExistingPurchases", false);
                        prefsEditor.commit();
                    }

                    // TODO: Handle very large list. Test for continuationToken != null then call getPurchases again
                }
            } catch (Throwable e) {
                e.printStackTrace();
            }
            isWaitingForPurchasesRequest = false;
        }
    }).start();
}