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, int defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Usage

From source file:androidx.media.MediaBrowserServiceCompat.java

List<MediaBrowserCompat.MediaItem> applyOptions(List<MediaBrowserCompat.MediaItem> list, final Bundle options) {
    if (list == null) {
        return null;
    }/*from w ww  .  j a  va2 s .  com*/
    int page = options.getInt(MediaBrowserCompat.EXTRA_PAGE, -1);
    int pageSize = options.getInt(MediaBrowserCompat.EXTRA_PAGE_SIZE, -1);
    if (page == -1 && pageSize == -1) {
        return list;
    }
    int fromIndex = pageSize * page;
    int toIndex = fromIndex + pageSize;
    if (page < 0 || pageSize < 1 || fromIndex >= list.size()) {
        return Collections.EMPTY_LIST;
    }
    if (toIndex > list.size()) {
        toIndex = list.size();
    }
    return list.subList(fromIndex, toIndex);
}

From source file:com.pitchedapps.primenumbercalculator.Calculator.java

License:asdf

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calculator);

    prefs = getSharedPreferences("prime", MODE_PRIVATE);
    editor = getSharedPreferences("prime", MODE_PRIVATE).edit();

    mDisplayView = findViewById(R.id.display);
    mInputEditText = (CalculatorEditText) findViewById(R.id.input);
    mResultEditText = (CalculatorEditText) findViewById(R.id.result);
    mPadViewPager = (ViewPager) findViewById(R.id.pad_pager);
    mDeleteButton = findViewById(R.id.del);
    mClearButton = findViewById(R.id.clr);
    mHelpVersionName = (TextView) findViewById(R.id.help_version_number);

    savedInstanceState = savedInstanceState == null ? Bundle.EMPTY : savedInstanceState;
    setState(CalculatorState.values()[savedInstanceState.getInt(KEY_CURRENT_STATE,
            CalculatorState.INPUT.ordinal())]);

    PackageInfo appInfo = null;/* w w w . j  ava2 s  . c  o m*/
    try {
        appInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    assert appInfo != null;
    mHelpVersionName.setText("v" + appInfo.versionName);

    mInputEditText.setText(savedInstanceState.getString(KEY_CURRENT_EXPRESSION, ""));
    mInputEditText.setEditableFactory(mInputEditableFactory);
    mInputEditText.addTextChangedListener(mInputTextWatcher);
    mInputEditText.setOnKeyListener(mInputOnKeyListener);
    mInputEditText.setOnTextSizeChangeListener(this);
    mDeleteButton.setOnLongClickListener(this);

    themeEngine();

    //Setup donations
    final IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {

            if (inventory != null) {
                if (inventory.hasPurchase("prime.donation.1") || inventory.hasPurchase("prime.donation.2")
                        || inventory.hasPurchase("prime.donation.3")
                        || inventory.hasPurchase("prime.donation.5")
                        || inventory.hasPurchase("prime.donation.10")) {
                    Log.d("PNC: ", "IAP inventory contains a donation");

                    mIsPremium = true;
                }
            }
            if (isPremium()) {
                mGoogleCatalog = GOOGLE_CATALOG_PRO;
            }
        }
    };

    if (isStoreVersion()) {
        mHelper = new IabHelper(Calculator.this, GOOGLE_PUBKEY);
        mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
            public void onIabSetupFinished(IabResult result) {
                if (!result.isSuccess()) {
                    Log.d("PNC: ", "In-app Billing setup failed: " + result);
                } else {
                    mHelper.queryInventoryAsync(false, mGotInventoryListener);
                }

            }
        });
    }

    initiateCredits();
}

From source file:bookapp.myapplication.LoginPage.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_page);

    mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
    mSignOutButton = (Button) findViewById(R.id.sign_out_button);
    mRevokeButton = (Button) findViewById(R.id.revoke_access_button);
    mStatus = (TextView) findViewById(R.id.sign_in_status);
    //mCirclesListView = (ListView) findViewById(R.id.circles_list);

    // Button listeners
    mSignInButton.setOnClickListener(this);
    mSignOutButton.setOnClickListener(this);
    mRevokeButton.setOnClickListener(this);

    // CheckBox listeners
    //((CheckBox) findViewById(R.id.request_auth_code_checkbox)).setOnCheckedChangeListener(this);
    //((CheckBox) findViewById(R.id.has_token_checkbox)).setOnCheckedChangeListener(this);
    /*//from   ww  w.  j  a v  a2s.c  o m
    mCirclesList = new ArrayList<String>();
    mCirclesAdapter = new ArrayAdapter<String>(
        this, R.layout.circle_member, mCirclesList);
    mCirclesListView.setAdapter(mCirclesAdapter);
    */
    if (savedInstanceState != null) {
        mSignInProgress = savedInstanceState.getInt(SAVED_PROGRESS, STATE_DEFAULT);
    }

    mGoogleApiClient = buildGoogleApiClient();
}

From source file:android.com.example.contactslist.ui.ContactsListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Check if this fragment is part of a two-pane set up or a single pane by reading a
    // boolean from the application resource directories. This lets allows us to easily specify
    // which screen sizes should use a two-pane layout by setting this boolean in the
    // corresponding resource size-qualified directory.
    //mIsTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes );

    // Let this fragment contribute menu items
    setHasOptionsMenu(true);/*from   ww w  .j a  v  a  2s  .  co m*/

    // Create the main contacts adapter
    mAdapter = new ContactsAdapter(getActivity());

    if (savedInstanceState != null) {
        // If we're restoring state after this fragment was recreated then
        // retrieve previous search term and previously selected search
        // result.
        mSearchTerm = savedInstanceState.getString(SearchManager.QUERY);
        mPreviouslySelectedSearchItem = savedInstanceState.getInt(STATE_PREVIOUSLY_SELECTED_KEY, 0);
    }

    /*
     * An ImageLoader object loads and resizes an image in the background and binds it to the
     * QuickContactBadge in each item layout of the ListView. ImageLoader implements memory
     * caching for each image, which substantially improves refreshes of the ListView as the
     * user scrolls through it.
     *
     * To learn more about downloading images asynchronously and caching the results, read the
     * Android training class Displaying Bitmaps Efficiently.
     *
     * http://developer.android.com/training/displaying-bitmaps/
     */
    mImageLoader = new ImageLoader(getActivity(), getListPreferredItemHeight()) {
        @Override
        protected Bitmap processBitmap(Object data) {
            // This gets called in a background thread and passed the data from
            // ImageLoader.loadImage().
            return loadContactPhotoThumbnail((String) data, getImageSize());
        }
    };

    // Set a placeholder loading image for the image loader
    mImageLoader.setLoadingImage(R.drawable.ic_contact_picture_holo_light);

    // Add a cache to the image loader
    mImageLoader.addImageCache(getActivity().getSupportFragmentManager(), 0.1f);
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

/** Called when the activity is first created. */
@Override//from   w w w.j  a v a  2  s  .  c o m
public void onCreate(Bundle savedInstanceState) {
    /* this was just a test      if(mLocationManager==null) {
             mLocationManager=(android.location.LocationManager) getSystemService(Context.LOCATION_SERVICE);
          }
    */
    //      TabHost host=this.getTabHost();
    //      host.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
    //         
    //         @Override
    //         public void onTabChanged(String tabId) {
    //            if(INeedToo.this._doingCreatingTabs==false) {
    //               if(tabId.equals("tab1")) {
    //                  INeedToo.this._forceNonCompany=true;
    //               }
    //            }
    //         }
    //      });
    super.onCreate(savedInstanceState);
    mLocationClient = new LocationClient(this, this, this);
    mLocationClient.connect();
    try {
        if (getIntent().getAction() != null && getIntent().getAction().equals("doPrimitiveDeletedNeed")) {
            transmitNetwork(getIntent().getStringExtra("phoneid"));
            return;
        }
    } catch (Exception eieio) {
        return;
    }
    try {
        /*
                    putExtra("needId",needId).
          putExtra("foreignNeedId",foreignNeedId).
          putExtra("phoneid",phoneid).
          putExtra("foreignLocationId",foreignLocationId)
                
         */
        if (getIntent().getAction() != null
                && getIntent().getAction().equals("transmitNetworkDeletedThisNeedByOnBehalfOf")) {
            long needId = getIntent().getLongExtra("needId", -11);
            long foreignNeedId = getIntent().getLongExtra("foreignNeedId", -11);
            String phoneId = getIntent().getStringExtra("phoneid");
            long foreignLocationId = getIntent().getLongExtra("foreignLocationId", -11);
            if (needId != -11 && foreignNeedId != -11 && foreignLocationId != -11 && isNothingNot(phoneId))
                transmitNetworkDeletedThisNeedByOnBehalfOf(needId, foreignNeedId, phoneId, foreignLocationId);
            return;
        }
    } catch (Exception ei3) {
        return;
    }

    /*bbhbb 2011-03-26*/ /*bbhbb2013_05_01 isn't this being done below?
                         *    Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler("")); */

    mHandler = new Handler();

    doBindService();
    mSingleton = this;
    ///////////mSingleton.log("onCreating_INeedToo", 1);

    if (getPackageName().toLowerCase().indexOf("trial") != -1 && !isSpecialPhone()) {
        if (!iveCheckedAuthorizationStatusForThisPhone) {
            doViewCount = true;
            iveCheckedAuthorizationStatusForThisPhone = true;
            final Timer jdTimer = new Timer("Registering");
            jdTimer.schedule(new TimerTask() {
                public void run() {
                    Thread thread = new Thread(new Runnable() {
                        public void run() {
                            Intent intent = new Intent(INeedToo.this, INeedWebService.class)
                                    .setAction("CheckStatus");
                            startService(intent);
                            jdTimer.cancel();
                        }
                    });
                    thread.setPriority(Thread.MIN_PRIORITY);
                    thread.run();
                }
            }, 3000, 1000 * 60 * 10);

        }
    } else {
        if (IS_ANDROID_VERSION) {
            if (!isSpecialPhone()
                    || INeedToo.mSingleton.getPhoneId().toLowerCase().equals("20013fc135cd6097xx")) {

                final Timer jdTimer = new Timer("Licensing");
                jdTimer.schedule(new TimerTask() {
                    public void run() {
                        Thread thread = new Thread(new Runnable() {
                            public void run() {
                                // Construct the LicenseCheckerCallback. The library calls this when done.        
                                mLicenseCheckerCallback = new MyLicenseCheckerCallback();
                                // Construct the LicenseChecker with a Policy.        
                                mChecker = new LicenseChecker(INeedToo.this,
                                        new ServerManagedPolicy(INeedToo.this,
                                                new AESObfuscator(SALT, getPackageName(),
                                                        //                           "com.mibr.android.intelligentreminder",
                                                        getDeviceId())),
                                        BASE64_PUBLIC_KEY // Your public licensing key.
                                );
                                mChecker.checkAccess(mLicenseCheckerCallback);
                            }
                        });
                        thread.setPriority(Thread.MIN_PRIORITY);
                        thread.run();
                    }
                }, 3000, 1000 * 60 * 10);
            }
        }
    }

    try {
        _logFilter = Integer
                .valueOf(getSharedPreferences(INeedToo.PREFERENCES_LOCATION, Preferences.MODE_PRIVATE)
                        .getString("LoggingLevel", "3"));
    } catch (Exception e) {
    }

    if (!INeedLocationService.USING_LOCATION_SERVICES) {

        int logFilter = 3;
        try {
            logFilter = Integer
                    .valueOf(getSharedPreferences(INeedToo.PREFERENCES_LOCATION, Preferences.MODE_PRIVATE)
                            .getString("LoggingLevel", "3"));
        } catch (Exception e) {
        }
        Intent jdIntent = new Intent(this, INeedTimerServices.class).putExtra("logFilter", logFilter);

        getApplicationContext().startService(jdIntent);
    }
    Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(""));
    if (INeedToo.mSingleton.getPhoneId().toLowerCase().equals("22a100000d9f25c5")) {
        DELAYPOSTTTS = 100;
    }

    // I don't need this because IHaveNeeds.onresume does it      getApplicationContext().startService(new Intent(this, INeedLocationService.class));
    if (!_doneSplashy) {
        _doneSplashy = true;
        if (!getVersionFile()) {
            stampVersion();
            showDialog(DIALOG_SPLASH);
        } else {
            //showDialog(DIALOG_SPLASH);
        }
    }
    if (allItems != null) {
        whereImAtInAllItems++;
        if (whereImAtInAllItems < allItems.size()) {
            showDialog(DOING_SAMPLE_NEEDS_DIALOG);
        } else {
            allItems = null;
        }
    }

    setTitle(getHeading());
    Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        _initialTabIndex = bundle.getInt("initialtabindex", 0);
        _didContact = bundle.getBoolean("iscontact", false);
        if (_initialTabIndex == 1) {
            _doingLocationCompany = bundle.getString("doingcompany");
        } else {
            _doingLocationCompany = null;
        }
    } else {
        _doingLocationCompany = null;
    }
    final TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Need",

            getResources().getDrawable(R.drawable.status_bar2_blackwhite))
            .setContent(new Intent(this, IHaveNeeds.class).putExtra("iscontact", this._didContact)));

    tabHost.addTab(tabHost.newTabSpec("tab2")
            .setIndicator("Location",
                    (BitmapDrawable) getResources().getDrawable(android.R.drawable.ic_menu_mapmode))
            .setContent(
                    new Intent(this, IHaveLocations.class).putExtra("doingcompany", _doingLocationCompany)));
    Intent intent = new Intent(this, NeedMap.class).putExtra("doingcompany", _doingLocationCompany);
    tabHost.addTab(tabHost.newTabSpec("tab2a")
            .setIndicator("Map", (BitmapDrawable) getResources().getDrawable(R.drawable.ic_dialog_map))
            .setContent(intent));
    /*
    tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator(
    "History",(BitmapDrawable) getResources().getDrawable(
          R.drawable.chart)).setContent(
                new Intent(this, IHaveHistory.class)));
    */
    tabHost.addTab(tabHost.newTabSpec("tab4")
            .setIndicator("System",
                    (BitmapDrawable) getResources().getDrawable(R.drawable.status_bar1_blackwhite))
            .setContent(new Intent(this, ListPlus.class)));
    /*      tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator(
    "Need",
    scaleTo((BitmapDrawable) getResources().getDrawable(
          R.drawable.status_bar2_blackwhite), 36f)).setContent(
                new Intent(this, IHaveNeeds.class).putExtra("iscontact", this._didContact)));
            
    tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator(
       "Location",
       scaleTo((BitmapDrawable) getResources().getDrawable(
             android.R.drawable.ic_menu_mapmode), 36f)).setContent(
                   new Intent(this, IHaveLocations.class).putExtra("doingcompany", _doingLocationCompany)));
    tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator(
    "History",
    scaleTo((BitmapDrawable) getResources().getDrawable(
          R.drawable.chart), 36f)).setContent(
                new Intent(this, IHaveHistory.class)));
    tabHost.addTab(tabHost.newTabSpec("tab4").setIndicator(
    "System",
    scaleTo((BitmapDrawable) getResources().getDrawable(
          R.drawable.status_bar1_blackwhite), 31f)).setContent(
                new Intent(this, ListPlus.class)));
    */
    tabHost.setCurrentTab(_initialTabIndex);
    boolean networkingOutbound = getSharedPreferences(INeedToo.PREFERENCES_LOCATION, Preferences.MODE_PRIVATE)
            .getBoolean("Networking_Outbound_Enabled", false);
    if (INeedWebService.mSingleton == null) {

        if (networkingOutbound) {
            enableTransmitting();
        }
        if (getSharedPreferences(INeedToo.PREFERENCES_LOCATION, Preferences.MODE_PRIVATE)
                .getBoolean("Networking_Inbound_Enabled", false)) {
            enableReceiving();
        }
    }
}

From source file:com.firefly.sample.castcompanionlibrary.cast.player.VideoCastControllerFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mCastConsumer = new MyCastConsumer();
    Bundle bundle = getArguments();//from w  w w . j a  v a2s  .com
    if (null == bundle) {
        return;
    }
    Bundle extras = bundle.getBundle(EXTRAS);
    Bundle mediaWrapper = extras.getBundle(VideoCastManager.EXTRA_MEDIA);

    // Retain this fragment across configuration changes.
    setRetainInstance(true);

    if (extras.getBoolean(VideoCastManager.EXTRA_HAS_AUTH)) {
        mOverallState = OverallState.AUTHORIZING;
        mMediaAuthService = mCastManager.getMediaAuthService();
        handleMediaAuthTask(mMediaAuthService);
        showImage(Utils.getImageUrl(mMediaAuthService.getMediaInfo(), 1));
    } else if (null != mediaWrapper) {
        mOverallState = OverallState.PLAYBACK;
        boolean shouldStartPlayback = extras.getBoolean(VideoCastManager.EXTRA_SHOULD_START);
        String customDataStr = extras.getString(VideoCastManager.EXTRA_CUSTOM_DATA);
        JSONObject customData = null;
        if (!TextUtils.isEmpty(customDataStr)) {
            try {
                customData = new JSONObject(customDataStr);
            } catch (JSONException e) {
                LOGE(TAG, "Failed to unmarshalize custom data string: customData=" + customDataStr, e);
            }
        }
        MediaInfo info = Utils.toMediaInfo(mediaWrapper);
        int startPoint = extras.getInt(VideoCastManager.EXTRA_START_POINT, 0);
        onReady(info, shouldStartPlayback, startPoint, customData);
    }
}

From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);

    String id = savedInstanceState.getString(Constants.MAIN_NOW_PLAYING);
    FragmentManager fm = getSupportFragmentManager();
    nowPlayingFragment = (NowPlayingFragment) fm.findFragmentByTag(id);

    String secondaryId = savedInstanceState.getString(Constants.MAIN_NOW_PLAYING_SECONDARY);
    if (secondaryId != null) {
        secondaryFragment = (SubsonicFragment) fm.findFragmentByTag(secondaryId);

        nowPlayingFragment.setPrimaryFragment(false);
        secondaryFragment.setPrimaryFragment(true);

        FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
        trans.hide(nowPlayingFragment);/*from   www  .  j  a va2s. c  o  m*/
        trans.commit();
    }

    if (drawerToggle != null && backStack.size() > 0) {
        drawerToggle.setDrawerIndicatorEnabled(false);
    }

    if (savedInstanceState.getInt(Constants.MAIN_SLIDE_PANEL_STATE,
            -1) == SlidingUpPanelLayout.PanelState.EXPANDED.hashCode()) {
        panelSlideListener.onPanelExpanded(null);
    }
}

From source file:org.dvbviewer.controller.ui.fragments.TimerDetails.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    cal = GregorianCalendar.getInstance();
    Date now = new Date();
    prefs = new DVBViewerPreferences(getSherlockActivity());
    if (timer == null && savedInstanceState == null) {
        timer = new Timer();
        timer.setId(getArguments().getLong(EXTRA_ID, 0l));
        timer.setTitle(getArguments().getString(EXTRA_TITLE));
        timer.setChannelName(getArguments().getString(EXTRA_CHANNEL_NAME));
        timer.setChannelId(getArguments().getLong(EXTRA_CHANNEL_ID, 0));
        Date start = new Date(getArguments().getLong(EXTRA_START, now.getTime()));
        Date end = new Date(getArguments().getLong(EXTRA_END, now.getTime()));
        timer.setStart(start);//from w  w  w .  j  a v  a2s  . co m
        timer.setEnd(end);
        if (timer.getId() <= 0l) {
            timer.setTimerAction(prefs.getInt(DVBViewerPreferences.KEY_TIMER_DEF_AFTER_RECORD, 0));
        } else {
            timer.setTimerAction(getArguments().getInt("action", 0));
        }
    } else if (savedInstanceState != null) {
        timer = new Timer();
        timer.setId(savedInstanceState.getLong(EXTRA_ID, 0));
        timer.setTitle(savedInstanceState.getString(EXTRA_TITLE));
        timer.setChannelName(savedInstanceState.getString(EXTRA_CHANNEL_NAME));
        timer.setChannelId(savedInstanceState.getLong(EXTRA_CHANNEL_ID, 0));
        timer.setStart(new Date(savedInstanceState.getLong(EXTRA_START, now.getTime())));
        timer.setEnd(new Date(savedInstanceState.getLong(EXTRA_END, now.getTime())));
        timer.setTimerAction(savedInstanceState.getInt(EXTRA_ACTION, 0));
    }

}