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:it.sineo.android.tileMapEditor.TileMap.java

public TileMap(Bundle b) {
    name = b.getString("name");

    rows = b.getInt("rows");
    columns = b.getInt("columns");
    scale = b.getFloat("scale");
    xOff = b.getFloat("xOff");
    yOff = b.getFloat("yoff");

    tilePaths = new String[rows][columns];
    tileBitmaps = new Bitmap[rows][columns];
    tileAngles = new byte[rows][columns];
    tileMatrices = new Matrix[rows][columns];

    for (int idxRow = 0; idxRow < rows; idxRow++) {
        for (int idxCol = 0; idxCol < columns; idxCol++) {
            if (b.containsKey("paths_" + idxRow + "_" + idxCol)) {
                tilePaths[idxRow][idxCol] = b.getString("paths_" + idxRow + "_" + idxCol);
                tileAngles[idxRow][idxCol] = b.getByte("angles_" + idxRow + "_" + idxCol);
            }/*  ww w .  ja v  a2  s  .  com*/
        }
    }
}

From source file:com.commonsware.cwac.colormixer.ColorMixer.java

@Override
public void onRestoreInstanceState(Parcelable ss) {
    Bundle state = (Bundle) ss;

    super.onRestoreInstanceState(state.getParcelable(SUPERSTATE));

    setColor(state.getInt(COLOR));
}

From source file:fr.julienvermet.bugdroid.service.ProductsIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Context context = getApplicationContext();

    Bundle bundle = intent.getExtras();
    String query = bundle.getString(QUERY);
    int instances_id = bundle.getInt(INSTANCES_ID);
    int accounts_id = bundle.getInt(ACCOUNTS_ID, -1);
    boolean forceReload = bundle.getBoolean(FORCE_RELOAD);

    ArrayList<Product> products = null;
    if (!forceReload) {
        String selection = Products.Columns.INSTANCES_ID.getName() + "=" + instances_id + " AND "
                + Products.Columns.ACCOUNTS_ID.getName() + "=" + accounts_id;
        String sortOrder = Products.Columns.NAME.getName();
        Cursor cursor = context.getContentResolver().query(Products.CONTENT_URI, Products.PROJECTION, selection,
                null, sortOrder);/* w ww .j  a v a2 s.  c  om*/
        if (cursor.getCount() > 0) {
            products = new ArrayList<Product>();
            for (int i = 0; i < cursor.getCount(); i++) {
                cursor.moveToPosition(i);
                Product product = Product.toProduct(cursor);
                products.add(product);
            }
            sendResult(intent, products);
            return;
        }
        cursor.close();
    }
    String jsonString = NetworkUtils.readJson(query).result;
    products = parse(jsonString);
    sendResult(intent, products);

    // Delete old products for instance
    String selection = Products.Columns.INSTANCES_ID + "=" + instances_id + " AND "
            + Products.Columns.ACCOUNTS_ID.getName() + "=" + accounts_id;
    context.getContentResolver().delete(Products.CONTENT_URI, selection, null);
    context.getContentResolver().bulkInsert(Products.CONTENT_URI,
            Product.toContentValues(products, instances_id, accounts_id));
}

From source file:com.analysedesgeeks.android.PodcastActivity.java

@Override
public void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState != null) {
        position = savedInstanceState.getInt(Const.EXTRA_POSITION);
    }/*from  www  .ja v  a  2s . c  om*/
}

From source file:angeloid.dreamnarae.TTS_Biling.java

void Biling_Friends() {
    try {/*w  w  w  . j  a va  2 s .  co m*/
        // Query Already Purchased
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        ArrayList<String> ownedSkus = null;

        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

        // Purchase it

        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));

        // Check
        ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

    } catch (Exception e) {
    }
}

From source file:angeloid.dreamnarae.TTS_Biling.java

void Biling_Narae() {
    try {/* ww  w .  j  a  va 2s  .  c  om*/
        // Query Already Purchased
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        ArrayList<String> ownedSkus = null;

        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

        // Purchase it

        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));

        // Check
        ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

    } catch (Exception e) {
    }
}

From source file:com.evvsoft.treeview.demo.DemoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mTheme = savedInstanceState.getInt(IDENT_THEME);
        if (mTheme > 0)
            setTheme(mTheme);/*  w w  w . j  av  a  2  s.  c  o m*/
        mIndicator = savedInstanceState.getInt(IDENT_INDICATOR);
    }
    ;
    setContentView(R.layout.activity_demo);
    TreeView treeView = (TreeView) findViewById(R.id.treeView1);

    try {
        String jsonStr = null;
        if (savedInstanceState != null)
            jsonStr = savedInstanceState.getString(IDENT_JSON);
        if (jsonStr == null)
            jsonStr = "[{id:1,id_parent:null,name:name1},{id:3,id_parent:2,name:name3},{id:2,id_parent:null,name:name2},{id:4,id_parent:3,name:name4},{id:5,id_parent:4,name:name5},{id:6,id_parent:2,name:name6},{id:7,id_parent:6,name:name7},{id:8,id_parent:7,name:name8}]";

        JSONArray demoArray = new JSONArray(jsonStr);
        mAdapter = new SimpleJsonTreeViewAdapter(this, demoArray, from);

        View header = getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
        TextView tv = (TextView) header.findViewById(android.R.id.text1);
        tv.setText("Demo Header");
        treeView.addHeaderView(header);
        View footer = getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
        tv = (TextView) footer.findViewById(android.R.id.text1);
        tv.setText("Demo Footer");
        treeView.addFooterView(footer);

        if (mIndicator != 0)
            treeView.setGroupIndicatorResource(mIndicator);
        //treeView.setChoiceMode(TreeView.CHOICE_MODE_SINGLE);
        treeView.setAdapter(mAdapter);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.chess.genesis.activity.GameListLocalFrag.java

@Override
public boolean handleMessage(final Message msg) {
    switch (msg.what) {
    case DeleteLocalDialog.MSG:
    case RenameGameDialog.MSG:
        gamelist_adapter.update();// w w w. j  av  a  2 s. co  m
        break;
    case NewLocalGameDialog.MSG:
        final GameDataDB db = new GameDataDB(act);
        final Bundle bundle = (Bundle) msg.obj;

        final int gametype2 = bundle.getInt("gametype");
        final int gameopp = bundle.getInt("opponent");
        String gamename = bundle.getString("name");
        if (gamename.length() < 1)
            gamename = "untitled";

        final Bundle gamedata = db.newLocalGame(gamename, gametype2, gameopp);
        db.close();

        loadGame(gamedata);
        break;
    }
    return true;
}

From source file:net.kourlas.voipms_sms.Billing.java

public void preDonation(final Activity sourceActivity) {
    try {//www.  ja v a  2  s  .  c  o m
        Bundle ownedItems = billingService.getPurchases(3, applicationContext.getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0) {
            List<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
            for (String purchaseData : purchaseDataList) {
                JSONObject json = new JSONObject(purchaseData);
                String pid = json.getString("productId");
                final String token = json.getString("purchaseToken");

                if (pid.equals(applicationContext.getString(R.string.billing_pid_donation))) {
                    new AsyncTask<Void, Void, Void>() {
                        @Override
                        protected Void doInBackground(Void... params) {
                            try {
                                billingService.consumePurchase(3, sourceActivity.getPackageName(), token);
                            } catch (Exception ignored) {
                                // Do nothing.
                            }
                            return null;
                        }

                        @Override
                        protected void onPostExecute(Void aVoid) {
                            showDonationDialog(sourceActivity);
                        }
                    }.execute();
                    return;
                }
            }
        }
    } catch (Exception ignored) {
        // Do nothing.
    }

    showDonationDialog(sourceActivity);
}

From source file:com.cssweb.android.quote.QHHQActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.njzq_gridview);
    initPopupWindow();/* w ww . j  av  a  2s .c om*/
    mGrid = (MyGrid) findViewById(R.id.mainmenu_grid);
    Bundle bundle = getIntent().getExtras();
    menuId = bundle.getInt("menu_id");
    menuName = "";
    initMenuName(menuId, -1);
    initTitle(R.drawable.njzq_title_left_back, 0, menuName);

    //      alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    //      Intent intent = new Intent(this, AutoLoadAllStock.class);
    //      intent.putExtra("filetype", Global.QUOTE_HKSTOCK);
    //      pendingIntent = PendingIntent.getBroadcast(this, 0,
    //            intent, 0);
    //       alarmManager.cancel(pendingIntent);
}