List of usage examples for android.os Bundle getStringArrayList
@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key)
From source file:com.yourkey.billing.util.InAppBilling.java
private String testItemOwned() { // assume item is not owned boolean itemOwned = false; String jsonItemData = null;/*from www . java 2 s . co m*/ // Continuation token // This will be used if user owns many items and the system will // break it into multiple blocks. String continueToken = null; // loop in case of large numbers of owned items for (;;) { // define owned items bundle Bundle ownedItems = null; // load next block of owned items try { // get all items owned by the user ownedItems = inAppBillingService.getPurchases(IN_APP_BILLING_API_VERSION, packageName, itemType, continueToken); } // system error catch (Exception e) { return (exceptionMessage(PLAY_STORE_LOAD_OWNED_PRODUCT_FAILED, e)); } // extract the response code from the bundle int result = getResponseCodeFromBundle(ownedItems); if (result != RESULT_OK) { return (errorMessage(PLAY_STORE_LOAD_OWNED_PRODUCT_FAILED, result)); } // response must have the following three key value pairs if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST) || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) return (errorMessage(PLAY_STORE_LOAD_OWNED_PRODUCT_FAILED)); // get all items ArrayList<String> itemSkuArray = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST); ArrayList<String> itemDataArray = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureArray = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); // make sure all three arrays have the same size int arraySize = itemSkuArray.size(); if (itemDataArray.size() != arraySize || signatureArray.size() != arraySize) return (errorMessage(PLAY_STORE_LOAD_OWNED_PRODUCT_FAILED)); // verify signatures of all items for (int Index = 0; Index < arraySize; Index++) { // item information String ownedItemSku = itemSkuArray.get(Index); String ownedItemData = itemDataArray.get(Index); String signature = signatureArray.get(Index); // verify signature if (!verifySignature(ownedItemData, signature)) return (errorMessage(PLAY_STORE_LOAD_OWNED_PRODUCT_FAILED)); // test for our item sku if (ownedItemSku.equals(itemSku)) { // our item is owned by user itemOwned = true; jsonItemData = ownedItemData; } // NOTE TO PROGRAMMERS // the ownedItemData contains the following information // it must be converted to JSON object // JSONOBJECT jsonObject = new JSONOBJECT(ownedItemData); // "orderId":"12999763169054705758.1371079406387615" // "packageName":"com.example.app", // "productId":"exampleSku", // "purchaseTime":1345678900000, (msec since 1970/01/01) // "purchaseState":0, // 0-purchased, 1 canceled, 2 refunded // "developerPayload":"example developer payload" // "purchaseToken" : "122333444455555", } // get continuation token continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN); // if continuation token is blank or empty, break out of the loop if (TextUtils.isEmpty(continueToken)) break; } // item is not owned if (!itemOwned) return (RESULT_TEXT_ITEM_NOT_OWNED); // purchase item if (!consumeActivity) return (RESULT_TEXT_ITEM_ALREADY_OWNED); // consume item // get the purchase token try { // create json object for item data JSONObject json = new JSONObject(jsonItemData); // get purchase token String itemPurchaseToken = json.optString(KEY_PURCHASE_TOKEN); // consume this item int result = inAppBillingService.consumePurchase(IN_APP_BILLING_API_VERSION, packageName, itemPurchaseToken); if (result != RESULT_OK) { return (errorMessage(PLAY_STORE_CONSUME_PRODUCT_FAILED, result)); } } catch (Exception e) { return (exceptionMessage(PLAY_STORE_CONSUME_PRODUCT_FAILED, e)); } // the item was consumed but return with already owned return (RESULT_TEXT_ITEM_ALREADY_OWNED); }
From source file:org.inaturalist.android.GuideDetails.java
/** Called when the activity is first created. */ @Override//from w w w.j av a 2 s.co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.guide_details); mHandler = new Handler(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mGuideMenu = (ListView) findViewById(R.id.guide_menu); mFilter = new GuideTaxonFilter(); ActionBar actionBar = getSupportActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setIcon(android.R.color.transparent); final Intent intent = getIntent(); if (mApp == null) { mApp = (INaturalistApp) getApplicationContext(); } if (savedInstanceState == null) { mGuide = (BetterJSONObject) intent.getSerializableExtra("guide"); } else { mGuide = (BetterJSONObject) savedInstanceState.getSerializable("guide"); mGuideXmlFilename = savedInstanceState.getString("guideXmlFilename"); if (mGuideXmlFilename != null) mGuideXml = new GuideXML(GuideDetails.this, mGuide.getInt("id").toString(), mGuideXmlFilename); mFilter.setSearchText(savedInstanceState.getString("filterSearchText")); mFilter.setTags(savedInstanceState.getStringArrayList("filterTags")); mIsDownloading = savedInstanceState.getBoolean("isDownloading"); mDownloadProgress = savedInstanceState.getInt("downloadProgress", 0); } if (mGuide == null) { finish(); return; } actionBar.setTitle(mGuide.getString("title")); mTaxaGuideReceiver = new GuideTaxaReceiver(); IntentFilter filter = new IntentFilter(INaturalistService.ACTION_GUIDE_XML_RESULT); Log.i(TAG, "Registering ACTION_GUIDE_XML_RESULT"); registerReceiver(mTaxaGuideReceiver, filter); mSearchText = (EditText) findViewById(R.id.search_filter); mSearchText.setEnabled(false); mSearchText.setText(mFilter.getSearchText()); mSearchText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (mAdapter != null) { mFilter.setSearchText(s.toString()); if (mTypingTask != null) { mHandler.removeCallbacks(mTypingTask); } mTypingTask = new Runnable() { @Override public void run() { updateTaxaByFilter(); } }; mHandler.postDelayed(mTypingTask, 400); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); mProgress = (ProgressBar) findViewById(R.id.progress); mTaxaEmpty = (TextView) findViewById(R.id.guide_taxa_empty); mGuideTaxaGrid = (GridViewExtended) findViewById(R.id.taxa_grid); mGuideTaxaGrid.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { GuideTaxonXML taxon = (GuideTaxonXML) arg1.getTag(); // Show taxon details Intent intent = new Intent(GuideDetails.this, GuideTaxonActivity.class); intent.putExtra("guide_taxon", true); intent.putExtra("guide_id", mGuideXml.getID()); intent.putExtra("taxon_id", taxon.getTaxonId()); intent.putExtra("guide_xml_filename", mGuideXmlFilename); startActivity(intent); } }); mProgress.setVisibility(View.VISIBLE); mGuideTaxaGrid.setVisibility(View.GONE); mTaxaEmpty.setVisibility(View.GONE); if (mGuideXml == null) { // Get the guide's XML file int guideId = mGuide.getInt("id"); Intent serviceIntent = new Intent(INaturalistService.ACTION_GUIDE_XML, null, GuideDetails.this, INaturalistService.class); serviceIntent.putExtra(INaturalistService.ACTION_GUIDE_ID, guideId); startService(serviceIntent); } LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View footerView = inflater.inflate(R.layout.guide_menu_footer, null, false); mDescription = (TextView) footerView.findViewById(R.id.description); mEditorName = (TextView) footerView.findViewById(R.id.editorName); mLicense = (TextView) footerView.findViewById(R.id.license); mDownloadTitle = (TextView) footerView.findViewById(R.id.downloadTitle); mDownloadSubtitle = (TextView) footerView.findViewById(R.id.downloadSubtitle); mDownloadingSubtitle = (TextView) footerView.findViewById(R.id.downloadingSubtitle); mDownloadGuideImage = (ImageView) footerView.findViewById(R.id.downloadGuideImage); mDownloadingGuide = (View) footerView.findViewById(R.id.downloadingGuide); mDownloadingProgress = (ProgressBar) footerView.findViewById(R.id.downloadingProgress); mDownloadGuide = (View) footerView.findViewById(R.id.downloadGuide); mGuideMenu.addFooterView(footerView); if (mIsDownloading) { refreshGuideSideMenu(); mApp.setDownloadCallback(this); } if (mGuideXml != null) { mTaxa = new ArrayList<GuideTaxonXML>(); mAdapter = new TaxaListAdapter(GuideDetails.this, mTaxa); updateTaxaByFilter(); mProgress.setVisibility(View.GONE); updateSideMenu(); } }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeFiveDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(fiveDollars);/* w ww .j a v a 2 s .c o m*/ Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(fiveDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeOneDollar() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(oneDollar);/*from w ww .j a va2s . c o m*/ Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(oneDollar)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeTenDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(tenDollars);// w ww . j a va 2s . co m Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(tenDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (SendIntentException e) { e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeTwentyDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(twentyDollars);/*from w ww. j av a 2 s. c o m*/ Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(twentyDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeFiftyDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(fiftyDollars);//from ww w .ja va2s .c o m Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(fiftyDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeHundredDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(hundredDollars); Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(hundredDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); }//w w w .jav a 2 s. c o m } } // } catch (RemoteException e) { // e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SendIntentException e) { // e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributetwoDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(twoDollars);/* w w w . ja v a2 s . c om*/ Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(twoDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }
From source file:uk.co.senab.photoview.sample.ViewPagerActivity.java
public void contributeThreeDollars() { new Thread(new Runnable() { public void run() { ArrayList skuList = new ArrayList(); skuList.add(threeDollars);/*from w w w . j a v a2 s. c om*/ Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); final Bundle skuDetails; try { skuDetails = mservice.getSkuDetails(3, getPackageName(), "inapp", querySkus); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); String sku = object.getString("productId"); String price = object.getString("price"); if (sku.equals(threeDollars)) { System.out.println("price " + price); Bundle buyIntentBundle = mservice.getBuyIntent(3, getPackageName(), sku, "inapp", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ"); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } } } // } catch (RemoteException e) { // e.printStackTrace(); } catch (JSONException e) { // e.printStackTrace(); } catch (SendIntentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }).start(); }