List of usage examples for android.os Bundle getInt
public int getInt(String key)
From source file:com.kuaichumen.whistle.admin.CaptureActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); type = savedInstanceState.getInt("type"); }
From source file:app.hacked.ChallengeListFragment.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)); }// ww w. ja v a2 s . co m if (getActivity().findViewById(R.id.ChallengeDetails) != null && savedInstanceState == null) { ChallengeWelcomeFragment fragment = new ChallengeWelcomeFragment(); getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.ChallengeDetails, fragment) .commit(); } getData(); }
From source file:com.sunho.nating.fragments.DetailUnivFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { FrameLayout root = (FrameLayout) view; context = view.getContext();/* w w w. j a v a 2s . co m*/ assert context != null; // This is how the fragment looks at first. Since the transition is one-way, we don't need to make // this a Scene. View item = LayoutInflater.from(context).inflate(R.layout.item_gridview, root, false); assert item != null; bind(item); // We adjust the position of the initial image with LayoutParams using the values supplied // as the fragment arguments. Bundle args = getArguments(); FrameLayout.LayoutParams params = null; if (args != null) { params = new FrameLayout.LayoutParams(args.getInt(ARG_WIDTH), args.getInt(ARG_HEIGHT)); params.topMargin = args.getInt(ARG_Y); params.leftMargin = args.getInt(ARG_X); } root.addView(item, params); }
From source file:de.j4velin.wifiAutoOff.Locations.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); Database db = Database.getInstance(this); locations = db.getLocations();/*from w w w .j a va2s .c o m*/ db.close(); setContentView(R.layout.locations); findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { if (PREMIUM_ENABLED || locations.size() < 1) { startActivityForResult(new Intent(Locations.this, Map.class), REQUEST_LOCATION); } else { AlertDialog.Builder builder = new AlertDialog.Builder(Locations.this); builder.setMessage(R.string.buy_pro); builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { try { Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), "de.j4velin.wifiautomatic.billing.pro", "inapp", getPackageName()); if (buyIntentBundle.getInt("RESPONSE_CODE") == 0) { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); startIntentSenderForResult(pendingIntent.getIntentSender(), REQUEST_BUY, null, 0, 0, 0); } } catch (Exception e) { if (BuildConfig.DEBUG) Logger.log(e); Toast.makeText(Locations.this, e.getClass().getName() + ": " + e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); } } }); mRecyclerView = (RecyclerView) findViewById(R.id.locations); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); mAdapter = new LocationsAdapter(); mRecyclerView.setAdapter(mAdapter); PREMIUM_ENABLED |= getSharedPreferences("settings", Context.MODE_PRIVATE).getBoolean("pro", false); if (!PREMIUM_ENABLED) { bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND") .setPackage("com.android.vending"), mServiceConn, Context.BIND_AUTO_CREATE); } findViewById(R.id.timeoutwarning).setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { getSharedPreferences(getPackageName() + "_preferences", Context.MODE_MULTI_PROCESS).edit() .putInt("no_network_timeout", 5).commit(); v.setVisibility(View.GONE); } }); }
From source file:app.hacked.ScheduleListFragment.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 .ja va 2 s . co m*/ if (getActivity().findViewById(R.id.ScheduleDetails) != null && savedInstanceState == null) { ScheduleWelcomeFragment fragment = new ScheduleWelcomeFragment(); getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.ScheduleDetails, fragment) .commit(); } getData(); /*if(savedInstanceState != null) progressBar.setVisibility(View.GONE);*/ }
From source file:com.anjlab.android.iab.v3.BillingProcessor.java
private SkuDetails getSkuDetails(String productId, String purchaseType) { if (billingService != null) { try {//from w ww.j a v a 2s .co m ArrayList<String> skuList = new ArrayList<String>(); skuList.add(productId); Bundle products = new Bundle(); products.putStringArrayList(Constants.PRODUCTS_LIST, skuList); 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) { for (String responseLine : skuDetails.getStringArrayList(Constants.DETAILS_LIST)) { JSONObject object = new JSONObject(responseLine); String responseProductId = object.getString(Constants.RESPONSE_PRODUCT_ID); if (productId.equals(responseProductId)) return new SkuDetails(object); } } else { if (eventHandler != null) eventHandler.onBillingError(response, null); Log.e(LOG_TAG, String.format("Failed to retrieve info for %s: error %d", productId, response)); } } catch (Exception e) { Log.e(LOG_TAG, String.format("Failed to call getSkuDetails %s", e.toString())); } } return null; }
From source file:com.chess.genesis.activity.GameListOnlineFrag.java
@Override public boolean handleMessage(final Message msg) { switch (msg.what) { case DeleteArchiveDialog.MSG: case ReadAllMsgsDialog.MSG: updateGameList();//w w w . j a v a 2 s.c o m break; case NewOnlineGameDialog.MSG: Bundle data = (Bundle) msg.obj; if (data.getInt("opponent") == Enums.INVITE) { new InviteOptionsDialog(act, handle, data).show(); return true; } progress.setText("Sending Newgame Request"); String gametype = Enums.GameType(data.getInt("gametype")); net.join_game(gametype); new Thread(net).start(); break; case RematchConfirm.MSG: data = (Bundle) msg.obj; progress.setText("Sending Newgame Request"); final String opponent = data.getString("opp_name"); String color = Enums.ColorType(data.getInt("color")); gametype = Enums.GameType(data.getInt("gametype")); net.new_game(opponent, gametype, color); new Thread(net).start(); break; case NudgeConfirm.MSG: progress.setText("Sending Nudge"); final String gameid = (String) msg.obj; net.nudge_game(gameid); new Thread(net).start(); break; case InviteOptionsDialog.MSG: data = (Bundle) msg.obj; progress.setText("Sending Newgame Request"); gametype = Enums.GameType(data.getInt("gametype")); color = Enums.ColorType(data.getInt("color")); net.new_game(data.getString("opp_name"), gametype, color); new Thread(net).start(); break; case SyncClient.MSG: case NetworkClient.JOIN_GAME: JSONObject json = (JSONObject) msg.obj; try { if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(act, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } if (msg.what == SyncClient.MSG || msg.what == NetworkClient.JOIN_GAME) { progress.setText("Checking Game Pool"); updateGameList(); GenesisNotifier.clearNotification(act, GenesisNotifier.YOURTURN_NOTE | GenesisNotifier.NEWMGS_NOTE); net.pool_info(); new Thread(net).start(); } else { progress.remove(); } } catch (final JSONException e) { throw new RuntimeException(e.getMessage(), e); } break; case NetworkClient.POOL_INFO: json = (JSONObject) msg.obj; try { if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(act, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } final JSONArray games = json.getJSONArray("games"); final PrefEdit pref = new PrefEdit(act); pref.putString(R.array.pf_poolinfo, games.toString()); pref.commit(); act.findViewById(R.id.game_search).setVisibility((games.length() == 0) ? View.GONE : View.VISIBLE); progress.remove(); } catch (final JSONException e) { throw new RuntimeException(e.getMessage(), e); } break; case NetworkClient.NEW_GAME: case NetworkClient.NUDGE_GAME: json = (JSONObject) msg.obj; try { if (json.getString("result").equals("error")) { progress.remove(); Toast.makeText(act, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return true; } progress.setText("Updating Game List"); final SyncClient sync = new SyncClient(act, handle); new Thread(sync).start(); } catch (final JSONException e) { throw new RuntimeException(e.getMessage(), e); } break; } return true; }
From source file:com.idean.atthack.api.Param.java
/** * Add param value from Bundle to JsonObject * /*from w ww. ja v a2 s.co m*/ * @param obj * @param params */ public void addToJson(JSONObject obj, Bundle params) { if (params.containsKey(name())) { try { switch (type) { case BOOLEAN: obj.put(name(), params.getBoolean(name())); break; case FLOAT: obj.put(name(), params.getFloat(name())); break; case INTEGER: obj.put(name(), params.getInt(name())); break; case STRING: obj.put(name(), params.getString(name())); break; default: } } catch (JSONException e) { Log.w(TAG, "Unable to add param " + this + " to json"); } } }
From source file:com.flat20.fingerplay.FingerPlayActivity.java
private void subscribe() { try {/*from w ww . j ava2 s . co m*/ Bundle bundle = mBillingService.getBuyIntent(3, getPackageName(), IAP_SUBS_KEY, "subs", null); PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT"); if (bundle.getInt("RESPONSE_CODE") == 0) { startIntentSenderForResult(pendingIntent.getIntentSender(), REQUEST_PURCHASE, new Intent(), 0, 0, 0); } else { unableToVerifyLicense(getString(R.string.billing_error_during_process), true); } } catch (Exception e) { Log.e("Fingerplay", "Error subscribing", e); unableToVerifyLicense(getString(R.string.billing_error_during_process), true); } }
From source file:com.thunder.iap.IAPActivity.java
/** * this methods is needed when a user wants to buy a subscription * @param sku//from w w w . j ava2 s . c o m * @param developerPayload * @param buySubscriptionListener */ public void buySubscription(final String sku, final String developerPayload, final BuySubscriptionListener buySubscriptionListener) { this.buySubscriptionListener = buySubscriptionListener; new Thread(new Runnable() { @Override public void run() { try { Bundle bundle = mService.getBuyIntent(3, getPackageName(), sku, "subs", developerPayload); PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT"); if (bundle.getInt("RESPONSE_CODE") == 0) { // Start purchase flow (this brings up the Google Play UI). // Result will be delivered through onActivityResult(). try { startIntentSenderForResult(pendingIntent.getIntentSender(), RC_SUBS_BUY, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); buySubscriptionListener.onError(e); } } else { buySubscriptionListener.onServerError(bundle); } } catch (RemoteException e) { e.printStackTrace(); buySubscriptionListener.onError(e); } } }).start(); }