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:edu.rit.csh.androidwebnews.ComposeActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    hc.getNewsGroups(); // used for list of newsgroups to look through

    if (extras != null) {
        if (extras.containsKey("SUBJECT")) { // coming from a reply
            subject = extras.getString("SUBJECT");
            body = extras.getString("QUOTED_TEXT");
            parentId = extras.getInt("PARENT");
        }/*from w w w.  ja  v  a 2  s .c o  m*/
        // for when a new post is done from a newsgroup
        newsgroup = extras.getString("NEWSGROUP");
    }

    setContentView(R.layout.activity_compose);
    dialog = new InvalidApiKeyDialog(this);

    ArrayList<String> groupNames = new ArrayList<String>();
    listAdapter = new ArrayAdapter<String>(this, R.layout.rowlayout, groupNames);
    spinner = (Spinner) findViewById(R.id.newsgroupSpinner);
    if (parentId <= 0) {// do not display the spinner if it is a reply to a post
        spinner.setAdapter(listAdapter);
        spinner.setSelection(listAdapter.getPosition(newsgroup));
    } else {
        spinner.setVisibility(View.GONE);
    }

    subLine = (EditText) findViewById(R.id.subject_line);
    subLine.setText(subject);

    bodyText = (EditText) findViewById(R.id.post_body);
    bodyText.setText(body);

    setTitle("Compose");
}

From source file:com.parse.ParsePushBroadcastReceiver.java

/**
 * Retrieves the small icon to be used in a {@link Notification}. The default implementation uses
 * the icon specified by {@code com.parse.push.notification_icon} {@code meta-data} in your
 * {@code AndroidManifest.xml} with a fallback to the launcher icon for this package. To conform
 * to Android style guides, it is highly recommended that developers specify an explicit push
 * icon.//from w w  w .  j  av  a2  s .c  om
 *
 * @param context
 *      The {@code Context} in which the receiver is running.
 * @param intent
 *      An {@code Intent} containing the channel and data of the current push notification.
 * @return
 *      The resource id of the default small icon for the package
 *
 * @see <a href="http://developer.android.com/design/style/iconography.html#notification">Android Notification Style Guide</a>
 */
protected int getSmallIconId(Context context, Intent intent) {
    Bundle metaData = ManifestInfo.getApplicationMetadata(context);
    int explicitId = 0;
    if (metaData != null) {
        explicitId = metaData.getInt(PROPERTY_PUSH_ICON);
    }
    return explicitId != 0 ? explicitId : ManifestInfo.getIconId();
}

From source file:com.anjlab.android.iab.v3.BillingProcessor.java

private boolean loadPurchasesByType(String type, BillingCache cacheStorage) {
    if (!isInitialized())
        return false;
    try {/*ww  w .  j  a  v  a2  s. c om*/
        Bundle bundle = billingService.getPurchases(Constants.GOOGLE_API_VERSION, contextPackageName, type,
                null);
        if (bundle.getInt(Constants.RESPONSE_CODE) == Constants.BILLING_RESPONSE_RESULT_OK) {
            cacheStorage.clear();
            ArrayList<String> purchaseList = bundle.getStringArrayList(Constants.INAPP_PURCHASE_DATA_LIST);
            ArrayList<String> signatureList = bundle.getStringArrayList(Constants.INAPP_DATA_SIGNATURE_LIST);
            for (int i = 0; i < purchaseList.size(); i++) {
                String jsonData = purchaseList.get(i);
                JSONObject purchase = new JSONObject(jsonData);
                String signature = signatureList != null && signatureList.size() > i ? signatureList.get(i)
                        : null;
                cacheStorage.put(purchase.getString(Constants.RESPONSE_PRODUCT_ID), jsonData, signature);
            }
        }
        return true;
    } catch (Exception e) {
        if (eventHandler != null)
            eventHandler.onBillingError(Constants.BILLING_ERROR_FAILED_LOAD_PURCHASES, e);
        Log.e(LOG_TAG, e.toString());
    }
    return false;
}

From source file:com.jerrellmardis.amphitheatre.task.DownloadTaskHelper.java

public static void traverseSmbFiles(SmbFile root, NtlmPasswordAuthentication auth)
        throws SmbException, MalformedURLException {
    int fileCount = 0;
    boolean video_folder = false;
    final Video v = new Video();
    Handler h = new Handler(Looper.getMainLooper()) {
        @Override/*from  w ww  . j a  v a  2s  . co  m*/
        public void handleMessage(Message msg) {
            //                            super.handleMessage(msg);
            Video vid = (Video) msg.getData().getSerializable("VIDEO");
            Log.d(TAG, "Handle " + msg.getData().getInt("WHEN") + " " + vid.getName());
            updateSingleVideo(vid, null);
        }

    };

    for (SmbFile f : root.listFiles()) {
        if (f.getParent().contains("Entertainment Media")) {
            //                Log.d(TAG, "Discovered "+f.getPath()+" "+f.isDirectory());
        }
        if (f.isDirectory()) {
            try {
                //TODO Port VOB folder support to USB and internal storage
                SmbFile[] directoryContents = f.listFiles();
                //                    Log.d(TAG, "Going into directory "+f.getPath());
                //If this works, then we can explore
                //Let's do some quick name checking to for time savings
                if (f.getName().contains("Entertainment Media")) {
                    //                        Log.d(TAG, Arrays.asList(f.listFiles()).toString());
                }
                if (!f.getName().contains("iTunes") && !f.getName().contains("Digi Pix")
                        && !f.getName().contains("AppData") && !f.getName().startsWith(".")
                        && !f.getName().contains("Avid") && !f.getName().contains("Spotify")
                        && !f.getName().contains("audacity_temp") && !f.getName().contains("Media_previews")
                        && !f.getName().contains("GFX_previews")
                        && !f.getName().contains("Samsung Install Files") && !f.getName().contains("AE Renders")
                        && !f.getName().contains("LocalData") && !f.getName().contains("$RECYCLE")
                        && !f.getName().contains("Encore DVD") && !f.getName().contains("16 GB Photo card")
                        && !f.getName().contains("Ignore") && !f.getName().contains("Documents") //TEMP
                        && !f.getName().contains("Downloads") //TEMP
                        && !f.getName().contains("TypeGEMs") //TEMP
                        && !f.getName().contains("KofC7032Web") //TEMP
                        && !f.getName().contains("hype mobile docs") //TEMP
                        && !f.getName().contains("Thrive Music Video") //TEMP
                        /*&& f.getPath().contains("Entertainment") //TEMP*/
                        && !f.getName().contains("Preview Files")) {
                    Log.d(TAG, "Check " + f.getPath());
                    traverseSmbFiles(f, auth);
                } else {
                    //                        Log.d(TAG, "Don't check " + f.getPath());
                }
            } catch (Exception e) {
                //This folder isn't accessible
                Log.d(TAG, "Inaccessible: " + f.getName() + " " + e.getMessage());
                //This will save us time in the traversal
            }
        } else/* if(f.getPath().contains("Films"))*/ { //TEMP
            //Is this something we want to add?
            //                Log.d(TAG, "Non-directory "+f.getPath());
            if (VideoUtils.isVideoFile(f.getPath())) {
                Log.d(TAG, f.getName() + " is a video");
                //Perhaps. Let's do some checking.
                /* VOB check
                If the files are in a structure like:
                { Movie Name } -> VIDEO_TS -> VTS_nn_n.vob
                        
                Then use the movie name as the source, and each vob url will
                be added in a comma-separated list to the video url string
                */

                if (f.getPath().contains("VIDEO_TS")) {
                    Log.d(TAG, "Special case for " + f.getPath());
                    //We have a special case!
                    String grandparentPath = f.getPath().substring(0, f.getPath().indexOf("VIDEO_TS"));
                    SmbFile grandparent = new SmbFile(grandparentPath, auth);

                    //Let's delete this video and all like it from our video database
                    //TODO Makes more sense to not delete and replace a video, just to update in place
                    //                        Log.d(TAG, "Purge where video_url like "+"%" + grandparent.getPath().replace("'", "\'") + "%");
                    List<Video> videos = Select.from(Video.class).where(Condition.prop("video_url")
                            .like("%" + grandparent.getPath().replace("'", "\'") + "%")).list();
                    //                        Log.d(TAG, "Purging "+videos.size()+" item(s)");
                    for (Video vx : videos) {
                        //                            Log.d(TAG, "Deleting "+vx.getVideoUrl());
                        vx.delete();
                    }

                    v.setName(grandparent.getName().replace("/", "").replace("_", " ") + ".avi"); //FIXME VOB currently not supported
                    v.setSource(FileSource.SMB);
                    v.setIsMatched(true); //Kind of a lie, but we know it's a thing!
                    //Get all the video files
                    ArrayList<String> urls = new ArrayList<>();
                    for (SmbFile f2 : grandparent.listFiles()) {
                        for (SmbFile f3 : f2.listFiles()) {
                            if (VideoUtils.isVideoFile(f3.getPath())) {
                                //Presumably in order
                                urls.add(f3.getPath());
                            }
                        }
                    }
                    //                        Log.d(TAG, urls.toString()); //This works well
                    v.setVideoUrl(urls);
                    video_folder = true;
                } else {
                    //Add the video like normal
                    //Let's delete this video and all like it from our video database
                    List<Video> videos = Select.from(Video.class)
                            .where(Condition.prop("video_url").like("%" + f.getPath().replace("'", "''") + "%"))
                            .list();
                    //                        Log.d(TAG, "Purging "+videos.size()+" item(s)");
                    for (Video vx : videos) {
                        //                            Log.d(TAG, "Deleting "+vx.getVideoUrl());
                        vx.delete();
                    }

                    v.setName(f.getName());
                    v.setSource(FileSource.SMB);
                    v.setVideoUrl(f.getPath());

                    fileCount++;
                    //Send a request to update metadata every second, to prevent as many 429 errors and memory exceptions
                    Message m = new Message();
                    Bundle mBundle = new Bundle();
                    mBundle.putSerializable("VIDEO", v.clone());
                    mBundle.putInt("WHEN", (int) (1000 * fileCount + Math.round(Math.random() * 100)));
                    m.setData(mBundle);
                    //                        h.sendEmptyMessageDelayed(1000 * fileCount, 1000 * fileCount);
                    h.sendMessageDelayed(m, 1000 * fileCount);
                    Log.d(TAG, "Queued " + mBundle.getInt("WHEN") + "  -  " + v.getName());
                    v.save(); //Need to save here, otherwise purging won't work as expected
                }

                //                    Log.d(TAG, v.toString());

                //                    return;
            }
            //Ignore otherwise
        }
    }
    //Let's do VOB video
    if (video_folder) {
        //            Log.d(TAG, "Done rooting through "+root.getPath());
        Log.d(TAG, "Created info for VOB " + v.toString());
        fileCount++;
        //Send a request to update metadata every second, to prevent as many 429 errors and memory exceptions
        Message m = new Message();
        Bundle mBundle = new Bundle();
        mBundle.putSerializable("VIDEO", v.clone());
        m.setData(mBundle);
        //                        h.sendEmptyMessageDelayed(1000 * fileCount, 1000 * fileCount);
        h.sendMessageDelayed(m, 1000 * fileCount);
        Log.d(TAG, "Queued " + 1000 * fileCount + "  -  " + v.getName());
        v.save(); //Need to save here, otherwise purging won't work as expected
    }
}

From source file:com.onesignal.TrackGooglePurchase.java

private void sendPurchases(final ArrayList<String> skusToAdd, final ArrayList<String> newPurchaseTokens) {
    try {/*from   ww w . ja  v  a 2s. co m*/
        if (getSkuDetailsMethod == null) {
            getSkuDetailsMethod = getGetSkuDetailsMethod(IInAppBillingServiceClass);
            getSkuDetailsMethod.setAccessible(true);
        }

        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 userID then send purchases to server. If successful then mark them as tracked.
            if (purchasesToReport.length() > 0) {
                final JSONArray finalPurchasesToReport = purchasesToReport;
                OneSignal.idsAvailable(new IdsAvailableHandler() {
                    public void idsAvailable(String userId, String registrationId) {
                        OneSignal.sendPurchases(finalPurchasesToReport, newAsExisting,
                                new OneSignalRestClient.ResponseHandler() {
                                    public void onFailure(int statusCode, JSONObject response,
                                            Throwable throwable) {
                                        OneSignal.Log(OneSignal.LOG_LEVEL.WARN,
                                                "HTTP sendPurchases failed to send.", throwable);
                                        isWaitingForPurchasesRequest = false;
                                    }

                                    public void onSuccess(String response) {
                                        purchaseTokens.addAll(newPurchaseTokens);
                                        prefsEditor.putString("purchaseTokens", purchaseTokens.toString());
                                        prefsEditor.remove("ExistingPurchases");
                                        prefsEditor.commit();
                                        newAsExisting = false;
                                        isWaitingForPurchasesRequest = false;
                                    }
                                });
                    }
                });

            }
        }
    } catch (Throwable t) {
        OneSignal.Log(OneSignal.LOG_LEVEL.WARN, "Failed to track IAP purchases", t);
    }
}

From source file:fr.cph.chicago.core.activity.BusMapActivity.java

@Override
public void onRestoreInstanceState(final Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    busId = savedInstanceState.getInt(bundleBusId);
    busRouteId = savedInstanceState.getString(bundleBusRouteId);
    bounds = savedInstanceState.getStringArray(bundleBusBounds);
}

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

/**
 *
 * @param sku the item that the user wants to buy
 * @param developerPayload the developer payload string, more info here http://developer.android.com/training/in-app-billing/purchase-iab-products.html
 * @param buyItemListener//from  ww w . java  2  s  .  c  o m
 */
public void buyItem(final String sku, final String developerPayload, final BuyItemListener buyItemListener) {
    this.buyItemListener = buyItemListener;
    new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
                        developerPayload);
                int response = buyIntentBundle.getInt("RESPONSE_CODE");
                if (response == 0) {
                    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                    try {
                        startIntentSenderForResult(pendingIntent.getIntentSender(), RC_INAPP_BUY, new Intent(),
                                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                        //the onSuccess callback of the listener will be called on the method onActivityResult
                    } catch (IntentSender.SendIntentException e) {
                        e.printStackTrace();
                        buyItemListener.onError(e);
                    }
                } else {
                    buyItemListener.onServerError(buyIntentBundle);
                }
            } catch (RemoteException e) {
                e.printStackTrace();
                buyItemListener.onError(e);
            }
        }
    }).start();
}

From source file:fi.mikuz.boarder.gui.internet.DownloadBoard.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.internet_download_board);
    setProgressBarIndeterminateVisibility(true);

    mWaitDialog = new TimeoutProgressDialog(DownloadBoard.this, "Waiting for response", TAG, true);

    Bundle extras = getIntent().getExtras();
    mAction = extras.getInt(DownloadBoard.SHOW_KEY);

    if (mAction == SHOW_INTERNET_BOARD) {
        mBoardId = extras.getInt(InternetMenu.BOARD_ID_KEY);
        mLoggedIn = extras.getBoolean(DownloadBoardList.LOGGED_IN_KEY);

        if (mLoggedIn) {
            mUserId = extras.getString(InternetMenu.USER_ID_KEY);
            mSessionToken = extras.getString(InternetMenu.SESSION_TOKEN_KEY);
        }/*w  w w . ja  v a  2 s.  c  o m*/

        getBoard();
    } else if (mAction == SHOW_PREVIEW_BOARD) {
        mLoggedIn = false;

        XStream xstream = new XStream();
        JSONObject fakeMessage = (JSONObject) xstream.fromXML(extras.getString(DownloadBoard.JSON_KEY));
        String fakeMessageString = fakeMessage.toString();

        try {

            if (GlobalSettings.getSensitiveLogging())
                Log.v(TAG, "Got a preview: " + fakeMessageString);
            ConnectionSuccessfulResponse fakeResponse = new ConnectionSuccessfulResponse(
                    new JSONObject(fakeMessageString), InternetMenu.mGetBoardURL);
            onConnectionSuccessful(fakeResponse);
        } catch (JSONException e) {
            Log.e(TAG, "Error reading fake json message", e);
        }
    } else {
        throw new IllegalArgumentException("No proper action defined, action: " + mAction);
    }

}

From source file:pffy.mobile.flax.FlaxActivity.java

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {

    super.onRestoreInstanceState(savedInstanceState);

    this.mFoodCatId = savedInstanceState.getInt(getResources().getString(R.string.prefkey_int_foodcatid));
    this.mFoodItemId = savedInstanceState.getInt(getResources().getString(R.string.prefkey_int_fooditemid));

    this.setOutputNames(savedInstanceState.getString(getResources().getString(R.string.prefkey_str_foodnames)));
    this.setOutputFacts(savedInstanceState.getString(getResources().getString(R.string.prefkey_str_foodfacts)));

    // Refreshes drop down menus
    this.mSpinnerFoodCat.setSelection(this.mFoodCatId);
    this.mSpinnerFoodItem.setSelection(this.mFoodItemId);
}

From source file:com.androidzeitgeist.dashwatch.dashclock.ExtensionManager.java

/**
 * Returns a listing of all available (installed) extensions.
 *//*from   w ww . j  av a 2s.co  m*/
public List<ExtensionListing> getAvailableExtensions() {
    List<ExtensionListing> availableExtensions = new ArrayList<ExtensionListing>();
    PackageManager pm = mApplicationContext.getPackageManager();
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(DashClockExtension.ACTION_EXTENSION),
            PackageManager.GET_META_DATA);
    for (ResolveInfo resolveInfo : resolveInfos) {
        ExtensionListing listing = new ExtensionListing();
        listing.componentName = new ComponentName(resolveInfo.serviceInfo.packageName,
                resolveInfo.serviceInfo.name);
        listing.title = resolveInfo.loadLabel(pm).toString();
        Bundle metaData = resolveInfo.serviceInfo.metaData;
        if (metaData != null) {
            listing.protocolVersion = metaData.getInt("protocolVersion");
            listing.worldReadable = metaData.getBoolean("worldReadable", false);
            listing.description = metaData.getString("description");
            String settingsActivity = metaData.getString("settingsActivity");
            if (!TextUtils.isEmpty(settingsActivity)) {
                listing.settingsActivity = ComponentName
                        .unflattenFromString(resolveInfo.serviceInfo.packageName + "/" + settingsActivity);
            }
        }

        listing.icon = resolveInfo.loadIcon(pm);
        availableExtensions.add(listing);
    }

    return availableExtensions;
}