List of usage examples for android.os Bundle getInt
public int getInt(String key)
From source file:com.jetheis.android.grades.billing.googleplay.GooglePlayBillingWrapper.java
@Override public void requestPurchase(String itemId) { Log.d(Constants.TAG, "Requesting purchase of " + itemId); Bundle response; try {/*from w w w . j av a 2 s.c o m*/ response = mBoundService.makeGooglePlayPurchaseRequest(itemId); } catch (RemoteException e) { Log.e(Constants.TAG, "RemoteException: " + e.getLocalizedMessage()); return; } if (response.getInt( GooglePlayBillingConstants.GOOGLE_PLAY_BUNDLE_KEY_RESPONSE_CODE) != GooglePlayResponseCode.RESULT_OK .ordinal()) { return; } PendingIntent pendingIntent = response .getParcelable(GooglePlayBillingConstants.GOOGLE_PLAY_BUNDLE_KEY_PURCHASE_INTENT); try { mContext.startIntentSender(pendingIntent.getIntentSender(), new Intent(), 0, 0, 0); } catch (SendIntentException e) { Log.e(Constants.TAG, "SendIntentException: " + e.getLocalizedMessage()); } }
From source file:com.nextgis.firereporter.ScanexSubscriptionItem.java
protected void Prepare(GetFiresService c) { this.c = c;/*from www . j a v a 2 s . c om*/ nID = -1; bHasNews = false; mFillDataHandler = new Handler() { public void handleMessage(Message msg) { Bundle resultData = msg.getData(); boolean bHaveErr = resultData.getBoolean(GetFiresService.ERROR); if (bHaveErr) { SendError(resultData.getString(GetFiresService.ERR_MSG)); } else { int nType = resultData.getInt(GetFiresService.SOURCE); String sData = resultData.getString(GetFiresService.JSON); switch (nType) { case 5: FillData(nType, sData); break; default: break; } } }; }; mmoItems = new HashMap<Long, ScanexNotificationItem>(); }
From source file:me.henrytao.smoothappbarlayoutdemo.activity.BaseActivity.java
private void requestItemsForPurchase(final AsyncCallback<List<PurchaseItem>> callback) { if (mPurchaseItems != null && mPurchaseItems.size() > 0) { if (callback != null) { callback.onSuccess(mPurchaseItems); }//from www .j a v 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(DONATE_ITEMS)); 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.chess.genesis.data.GameDataDB.java
public void addLocalGame(final Bundle game) { final Object[] data = { game.getString("name"), game.getLong("ctime"), game.getLong("stime"), game.getInt("gametype"), game.getInt("opponent"), game.getString("history"), game.getString("zfen") }; db.execSQL(//from w w w.j a v a2 s . c o m "INSERT INTO localgames (name, ctime, stime, gametype, opponent, history, zfen) VALUES (?, ?, ?, ?, ?, ?, ?);", data); }
From source file:app.hacked.ProjectListFragment.java
@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)); }// w w w . j a va 2 s. c o m if (getActivity().findViewById(R.id.ProjectDetails) != null && savedInstanceState == null) { ProjectWelcomeFragment fragment = new ProjectWelcomeFragment(); getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.ProjectDetails, fragment) .commit(); } progressBar = view.findViewById(R.id.progressBar); if (savedInstanceState != null) progressBar.setVisibility(View.GONE); }
From source file:com.jetheis.android.makeitrain.billing.googleplay.GooglePlayBillingWrapper.java
public void requestVipStatus() { Bundle response; try {/* w w w.ja v a 2 s . com*/ response = mBoundService.makeGooglePlayPurchaseRequest(Constants.GOOGLE_PLAY_PRODUCT_ID); } catch (RemoteException e) { Log.e(Constants.TAG, "RemoteException: " + e.getLocalizedMessage()); return; } if (response.getInt(Constants.GOOGLE_PLAY_BUNDLE_KEY_RESPONSE_CODE) != GooglePlayResponseCode.RESULT_OK .ordinal()) { return; } PendingIntent pendingIntent = response.getParcelable(Constants.GOOGLE_PLAY_BUNDLE_KEY_PURCHASE_INTENT); try { mContext.startIntentSender(pendingIntent.getIntentSender(), new Intent(), 0, 0, 0); } catch (SendIntentException e) { Log.e(Constants.TAG, "SendIntentException: " + e.getLocalizedMessage()); } }
From source file:com.anjlab.android.iab.v3.BillingProcessor.java
private boolean purchase(Activity activity, String productId, String purchaseType) { if (!isInitialized() || TextUtils.isEmpty(productId) || TextUtils.isEmpty(purchaseType)) return false; try {/*from w w w .j a v a2s . c o m*/ String purchasePayload = purchaseType + ":" + UUID.randomUUID().toString(); savePurchasePayload(purchasePayload); Bundle bundle = billingService.getBuyIntent(Constants.GOOGLE_API_VERSION, contextPackageName, productId, purchaseType, purchasePayload); if (bundle != null) { int response = bundle.getInt(Constants.RESPONSE_CODE); if (response == Constants.BILLING_RESPONSE_RESULT_OK) { PendingIntent pendingIntent = bundle.getParcelable(Constants.BUY_INTENT); if (activity != null) activity.startIntentSenderForResult(pendingIntent.getIntentSender(), PURCHASE_FLOW_REQUEST_CODE, new Intent(), 0, 0, 0); else if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_LOST_CONTEXT, null); } else if (response == Constants.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) { if (!isPurchased(productId) && !isSubscribed(productId)) loadOwnedPurchasesFromGoogle(); if (eventHandler != null) { TransactionDetails details = getPurchaseTransactionDetails(productId); if (details == null) details = getSubscriptionTransactionDetails(productId); eventHandler.onProductPurchased(productId, details); } } else if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_FAILED_TO_INITIALIZE_PURCHASE, null); } return true; } catch (Exception e) { Log.e(LOG_TAG, e.toString()); } return false; }
From source file:com.nextgis.rehacompdemo.RoutingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_routing); String sRadius = PreferenceManager.getDefaultSharedPreferences(this).getString(Constants.PREF_RADIUS, "6"); mActivationDistance = Integer.parseInt(sRadius); int routeNum = -1; Bundle extras = getIntent().getExtras(); if (extras != null) { routeNum = extras.getInt(Constants.BUNDLE_ROUTE_ID); if (getSupportActionBar() != null) getSupportActionBar().setTitle(extras.getString(Constants.BUNDLE_ROUTE_NAME)); }/*www. j a va 2s. c om*/ if (routeNum == -1) return; mRoute = "route_" + routeNum; mPoints = "points_" + routeNum; mSteps = (ListView) findViewById(R.id.lv_steps); mAdapter = new StepAdapter(this, R.layout.item_step, getRouteSteps()); mSteps.setAdapter(mAdapter); mSteps.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mSteps.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // view.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); mSteps.requestFocusFromTouch(); mSteps.setSelection(position); } }); mMap = (MapDrawable) ((GISApplication) getApplication()).getMap(); new MapLoader().execute(); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, Constants.GPS_MIN_TIME, Constants.GPS_MIN_DIST, this); }
From source file:com.sunho.nating.fragments.DetailUnivFragment.java
private void bindFragment(View parent) { Bundle args = getArguments(); if (args == null) { return;//from ww w.java 2s. c o m } ImageView image = (ImageView) parent.findViewById(R.id.image); image.setImageResource(args.getInt(ARG_RESOURCE_ID)); TextView title = (TextView) parent.findViewById(R.id.title); title.setText(args.getString(ARG_TITLE)); listView = (ListView) parent.findViewById(R.id.list); listView.setDividerHeight(0); adapter = new CustomListAdapter(MainActivity.mActivity, placeList) { @Override public View getDataRow(int position, View convertView, ViewGroup parent) { return convertView; } }; listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(MainActivity.mContext, placeList.get(position).getOldAddress(), 0).show(); moveFragment(position); } }); listView.setOnScrollListener(new EndlessScrollListener() { @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { super.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); //lastListitem = (totalItemCount - 1 > 0) && (firstVisibleItem + visibleItemCount >= totalItemCount - 1); } @Override public void onLoadMore(int page, int totalItemsCount) { // Triggered only when new data needs to be appended to the list // Add whatever code is needed to append new items to your AdapterView Log.d(TAG, "==ListView Information=="); Log.d(TAG, "PageNumber : " + page); Log.d(TAG, "TotalCount : " + totalItemsCount); Log.d(TAG, "adpaterCount : " + adapter.getCount()); Log.d(TAG, "========================"); new GetDataTask().execute(); } }); new GetDataTask().execute(); }
From source file:com.mindmeapp.extensions.ExtensionData.java
/** * Deserializes the given {@link Bundle} representation of extension data, populating this * object./*w w w . j a v a2s . c om*/ */ 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.mStatusToDisplay = src.getString(KEY_STATUS_TO_DISPLAY); this.mStatusToSpeak = src.getString(KEY_STATUS_TO_SPEAK); this.mLanguageToSpeak = (Locale) src.getSerializable(KEY_LANGUAGE_TO_SPEAK); this.mViewsToDisplay = src.getParcelable(KEY_VIEWS_TO_DISPLAY); this.mContentDescription = src.getString(KEY_CONTENT_DESCRIPTION); this.mBackground = src.getInt(KEY_BACKGROUND); String backgroundUriString = src.getString(KEY_BACKGROUND_URI); this.mBackgroundUri = TextUtils.isEmpty(backgroundUriString) ? null : Uri.parse(backgroundUriString); }