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:cgeo.geocaching.CacheListActivity.java

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

    setTheme();//  w w w  .ja  va  2  s . c o m

    setContentView(R.layout.cacheslist_activity);

    // get parameters
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        type = Intents.getListType(getIntent());
        coords = extras.getParcelable(Intents.EXTRA_COORDS);
    } else {
        extras = new Bundle();
    }
    if (isInvokedFromAttachment()) {
        type = CacheListType.OFFLINE;
        if (coords == null) {
            coords = Geopoint.ZERO;
        }
    }
    if (type == CacheListType.NEAREST) {
        coords = Sensors.getInstance().currentGeo().getCoords();
    }

    setTitle(title);

    // Check whether we're recreating a previously destroyed instance
    if (savedInstanceState != null) {
        // Restore value of members from saved state
        currentFilter = savedInstanceState.getParcelable(STATE_FILTER);
        currentInverseSort = savedInstanceState.getBoolean(STATE_INVERSE_SORT);
        type = CacheListType.values()[savedInstanceState.getInt(STATE_LIST_TYPE, type.ordinal())];
        listId = savedInstanceState.getInt(STATE_LIST_ID);
    }

    initAdapter();

    prepareFilterBar();

    if (type.canSwitch) {
        initActionBarSpinner();
    }

    currentLoader = (AbstractSearchLoader) getSupportLoaderManager().initLoader(type.getLoaderId(), extras,
            this);

    // init
    if (CollectionUtils.isNotEmpty(cacheList)) {
        // currentLoader can be null if this activity is created from a map, as onCreateLoader() will return null.
        if (currentLoader != null && currentLoader.isStarted()) {
            showFooterLoadingCaches();
        } else {
            showFooterMoreCaches();
        }
    }

    if (isInvokedFromAttachment()) {
        listNameMemento.rememberTerm(extras.getString(Intents.EXTRA_NAME));
        importGpxAttachement();
    }
}

From source file:android.support.v17.leanback.app.BrowseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (getChildFragmentManager().findFragmentById(R.id.scale_frame) == null) {
        mHeadersFragment = new HeadersFragment();

        createMainFragment(mAdapter, mSelectedPosition);
        FragmentTransaction ft = getChildFragmentManager().beginTransaction().replace(R.id.browse_headers_dock,
                mHeadersFragment);//from w  ww  .  j av  a2s  .  co m

        if (mMainFragment != null) {
            ft.replace(R.id.scale_frame, mMainFragment);
        } else {
            // Empty adapter used to guard against lazy adapter loading. When this
            // fragment is instantiated, mAdapter might not have the data or might not
            // have been set. In either of those cases mFragmentAdapter will be null.
            // This way we can maintain the invariant that mMainFragmentAdapter is never
            // null and it avoids doing null checks all over the code.
            mMainFragmentAdapter = new MainFragmentAdapter(null);
            mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl());
        }

        ft.commit();
    } else {
        mHeadersFragment = (HeadersFragment) getChildFragmentManager()
                .findFragmentById(R.id.browse_headers_dock);
        mMainFragment = getChildFragmentManager().findFragmentById(R.id.scale_frame);
        mMainFragmentAdapter = ((MainFragmentAdapterProvider) mMainFragment).getMainFragmentAdapter();
        mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl());

        mIsPageRow = savedInstanceState != null ? savedInstanceState.getBoolean(IS_PAGE_ROW, false) : false;

        mSelectedPosition = savedInstanceState != null ? savedInstanceState.getInt(CURRENT_SELECTED_POSITION, 0)
                : 0;

        if (!mIsPageRow) {
            if (mMainFragment instanceof MainFragmentRowsAdapterProvider) {
                mMainFragmentRowsAdapter = ((MainFragmentRowsAdapterProvider) mMainFragment)
                        .getMainFragmentRowsAdapter();
            } else {
                mMainFragmentRowsAdapter = null;
            }
        } else {
            mMainFragmentRowsAdapter = null;
        }
    }

    mHeadersFragment.setHeadersGone(!mCanShowHeaders);
    if (mHeaderPresenterSelector != null) {
        mHeadersFragment.setPresenterSelector(mHeaderPresenterSelector);
    }
    mHeadersFragment.setAdapter(mAdapter);
    mHeadersFragment.setOnHeaderViewSelectedListener(mHeaderViewSelectedListener);
    mHeadersFragment.setOnHeaderClickedListener(mHeaderClickedListener);

    View root = inflater.inflate(R.layout.lb_browse_fragment, container, false);

    getProgressBarManager().setRootView((ViewGroup) root);

    mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame);
    mBrowseFrame.setOnChildFocusListener(mOnChildFocusListener);
    mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener);

    installTitleView(inflater, mBrowseFrame, savedInstanceState);

    mScaleFrameLayout = (ScaleFrameLayout) root.findViewById(R.id.scale_frame);
    mScaleFrameLayout.setPivotX(0);
    mScaleFrameLayout.setPivotY(mContainerListAlignTop);

    setupMainFragment();

    if (mBrandColorSet) {
        mHeadersFragment.setBackgroundColor(mBrandColor);
    }

    mSceneWithHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() {
        @Override
        public void run() {
            showHeaders(true);
        }
    });
    mSceneWithoutHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() {
        @Override
        public void run() {
            showHeaders(false);
        }
    });
    mSceneAfterEntranceTransition = TransitionHelper.createScene(mBrowseFrame, new Runnable() {
        @Override
        public void run() {
            setEntranceTransitionEndState();
        }
    });

    return root;
}

From source file:android.support.v17.leanback.app.BrowseSupportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    if (getChildFragmentManager().findFragmentById(R.id.scale_frame) == null) {
        mHeadersSupportFragment = new HeadersSupportFragment();

        createMainFragment(mAdapter, mSelectedPosition);
        FragmentTransaction ft = getChildFragmentManager().beginTransaction().replace(R.id.browse_headers_dock,
                mHeadersSupportFragment);

        if (mMainFragment != null) {
            ft.replace(R.id.scale_frame, mMainFragment);
        } else {// w ww  .  j a  v  a 2  s .  c o m
            // Empty adapter used to guard against lazy adapter loading. When this
            // fragment is instantiated, mAdapter might not have the data or might not
            // have been set. In either of those cases mFragmentAdapter will be null.
            // This way we can maintain the invariant that mMainFragmentAdapter is never
            // null and it avoids doing null checks all over the code.
            mMainFragmentAdapter = new MainFragmentAdapter(null);
            mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl());
        }

        ft.commit();
    } else {
        mHeadersSupportFragment = (HeadersSupportFragment) getChildFragmentManager()
                .findFragmentById(R.id.browse_headers_dock);
        mMainFragment = getChildFragmentManager().findFragmentById(R.id.scale_frame);
        mMainFragmentAdapter = ((MainFragmentAdapterProvider) mMainFragment).getMainFragmentAdapter();
        mMainFragmentAdapter.setFragmentHost(new FragmentHostImpl());

        mIsPageRow = savedInstanceState != null ? savedInstanceState.getBoolean(IS_PAGE_ROW, false) : false;

        mSelectedPosition = savedInstanceState != null ? savedInstanceState.getInt(CURRENT_SELECTED_POSITION, 0)
                : 0;

        if (!mIsPageRow) {
            if (mMainFragment instanceof MainFragmentRowsAdapterProvider) {
                mMainFragmentRowsAdapter = ((MainFragmentRowsAdapterProvider) mMainFragment)
                        .getMainFragmentRowsAdapter();
            } else {
                mMainFragmentRowsAdapter = null;
            }
        } else {
            mMainFragmentRowsAdapter = null;
        }
    }

    mHeadersSupportFragment.setHeadersGone(!mCanShowHeaders);
    if (mHeaderPresenterSelector != null) {
        mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector);
    }
    mHeadersSupportFragment.setAdapter(mAdapter);
    mHeadersSupportFragment.setOnHeaderViewSelectedListener(mHeaderViewSelectedListener);
    mHeadersSupportFragment.setOnHeaderClickedListener(mHeaderClickedListener);

    View root = inflater.inflate(R.layout.lb_browse_fragment, container, false);

    getProgressBarManager().setRootView((ViewGroup) root);

    mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame);
    mBrowseFrame.setOnChildFocusListener(mOnChildFocusListener);
    mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener);

    installTitleView(inflater, mBrowseFrame, savedInstanceState);

    mScaleFrameLayout = (ScaleFrameLayout) root.findViewById(R.id.scale_frame);
    mScaleFrameLayout.setPivotX(0);
    mScaleFrameLayout.setPivotY(mContainerListAlignTop);

    setupMainFragment();

    if (mBrandColorSet) {
        mHeadersSupportFragment.setBackgroundColor(mBrandColor);
    }

    mSceneWithHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() {
        @Override
        public void run() {
            showHeaders(true);
        }
    });
    mSceneWithoutHeaders = TransitionHelper.createScene(mBrowseFrame, new Runnable() {
        @Override
        public void run() {
            showHeaders(false);
        }
    });
    mSceneAfterEntranceTransition = TransitionHelper.createScene(mBrowseFrame, new Runnable() {
        @Override
        public void run() {
            setEntranceTransitionEndState();
        }
    });

    return root;
}

From source file:com.tweetlanes.android.core.view.TweetFeedFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    mProfileImageLoader = getApp().getProfileImageLoader();
    mPreviewImageLoader = getApp().getPreviewImageLoader();

    mContentHandle = TwitterManager.get().getContentHandle(getContentHandleBase(), getScreenName(),
            getLaneIdentifier(), getApp().getCurrentAccountKey());

    View resultView = inflater.inflate(R.layout.lane, null);
    configureLaneWidth(resultView);/*www .j  a  v a  2 s .  com*/

    mViewSwitcher = (ViewSwitcher) resultView.findViewById(R.id.profileSwitcher);
    mListHeadingTextView = (TextView) resultView.findViewById(R.id.list_heading);
    mListHeadingHideImage = (ImageView) resultView.findViewById(R.id.list_hide);
    mListHeadingHideImage.setOnClickListener(mListHeadingHideImageOnClickListener);
    mMultipleTweetSelectionCallback = new MultipleTweetSelectionCallback();
    mTweetFeedListAdapter = new TweetFeedListAdapter(inflater);

    mTweetFeedListView = (PullToRefreshListView) resultView.findViewById(R.id.pull_to_refresh_listview);
    mTweetFeedListView.getRefreshableView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    mTweetFeedListView.getRefreshableView().setMultiChoiceModeListener(mMultipleTweetSelectionCallback);
    mTweetFeedListView.getRefreshableView().setOnScrollListener(mTweetFeedOnScrollListener);
    mTweetFeedListView.getRefreshableView().setAdapter(mTweetFeedListAdapter);
    mTweetFeedListView.setOnRefreshListener(mTweetFeedOnRefreshListener);
    mTweetFeedListView.setOnLastItemVisibleListener(mTweetFeedOnLastItemVisibleListener);

    mRefreshTimestampsHandler.removeCallbacks(mRefreshTimestampsTask);
    mRefreshTimestampsHandler.postDelayed(mRefreshTimestampsTask, REFRESH_TIMESTAMPS_INTERVAL);

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeUpKeyDownReceiver,
            new IntentFilter("" + SystemEvent.VOLUME_UP_KEY_DOWN));
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mVolumeDownKeyDownReceiver,
            new IntentFilter("" + SystemEvent.VOLUME_DOWN_KEY_DOWN));

    if (savedInstanceState != null) {
        mTwitterStatusIdWhenRefreshed = savedInstanceState.containsKey("TwitterStatusIdWhenRefreshed")
                ? savedInstanceState.getLong("TwitterStatusIdWhenRefreshed")
                : 0L;
        mLastTwitterStatusIdSeen = savedInstanceState.containsKey("LastTwitterStatusIdSeen")
                ? savedInstanceState.getLong("LastTwitterStatusIdSeen")
                : 0L;
        mNewStatuses = savedInstanceState.getInt("NewStatuses", 0);
        mHidingListHeading = savedInstanceState.getBoolean("HidingListHeading", false);
    }

    configureInitialStatuses();

    return resultView;
}

From source file:cgeo.geocaching.CacheDetailActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState, R.layout.cachedetail_activity);

    // get parameters
    final Bundle extras = getIntent().getExtras();
    final Uri uri = AndroidBeam.getUri(getIntent());

    // try to get data from extras
    String name = null;/*from www .  j  av a  2 s  .  co m*/
    String guid = null;

    if (extras != null) {
        geocode = extras.getString(Intents.EXTRA_GEOCODE);
        name = extras.getString(Intents.EXTRA_NAME);
        guid = extras.getString(Intents.EXTRA_GUID);
    }

    // When clicking a cache in MapsWithMe, we get back a PendingIntent
    if (StringUtils.isEmpty(geocode)) {
        geocode = MapsMeCacheListApp.getCacheFromMapsWithMe(this, getIntent());
    }

    if (geocode == null && uri != null) {
        geocode = ConnectorFactory.getGeocodeFromURL(uri.toString());
    }

    // try to get data from URI
    if (geocode == null && guid == null && uri != null) {
        final String uriHost = uri.getHost().toLowerCase(Locale.US);
        final String uriPath = uri.getPath().toLowerCase(Locale.US);
        final String uriQuery = uri.getQuery();

        if (uriQuery != null) {
            Log.i("Opening URI: " + uriHost + uriPath + "?" + uriQuery);
        } else {
            Log.i("Opening URI: " + uriHost + uriPath);
        }

        if (uriHost.contains("geocaching.com")) {
            if (StringUtils.startsWith(uriPath, "/geocache/gc")) {
                geocode = StringUtils.substringBefore(uriPath.substring(10), "_").toUpperCase(Locale.US);
            } else {
                geocode = uri.getQueryParameter("wp");
                guid = uri.getQueryParameter("guid");

                if (StringUtils.isNotBlank(geocode)) {
                    geocode = geocode.toUpperCase(Locale.US);
                    guid = null;
                } else if (StringUtils.isNotBlank(guid)) {
                    geocode = null;
                    guid = guid.toLowerCase(Locale.US);
                } else {
                    showToast(res.getString(R.string.err_detail_open));
                    finish();
                    return;
                }
            }
        }
    }

    // no given data
    if (geocode == null && guid == null) {
        showToast(res.getString(R.string.err_detail_cache));
        finish();
        return;
    }

    // If we open this cache from a search, let's properly initialize the title bar, even if we don't have cache details
    setCacheTitleBar(geocode, name, null);

    final LoadCacheHandler loadCacheHandler = new LoadCacheHandler(this, progress);

    try {
        String title = res.getString(R.string.cache);
        if (StringUtils.isNotBlank(name)) {
            title = name;
        } else if (geocode != null && StringUtils.isNotBlank(geocode)) { // can't be null, but the compiler doesn't understand StringUtils.isNotBlank()
            title = geocode;
        }
        progress.show(this, title, res.getString(R.string.cache_dialog_loading_details), true,
                loadCacheHandler.disposeMessage());
    } catch (final RuntimeException ignored) {
        // nothing, we lost the window
    }

    final int pageToOpen = savedInstanceState != null ? savedInstanceState.getInt(STATE_PAGE_INDEX, 0)
            : Settings.isOpenLastDetailsPage() ? Settings.getLastDetailsPage() : 1;
    createViewPager(pageToOpen, new OnPageSelectedListener() {

        @Override
        public void onPageSelected(final int position) {
            if (Settings.isOpenLastDetailsPage()) {
                Settings.setLastDetailsPage(position);
            }
            // lazy loading of cache images
            if (getPage(position) == Page.IMAGES) {
                loadCacheImages();
            }
            requireGeodata = getPage(position) == Page.DETAILS;
            startOrStopGeoDataListener(false);

            // dispose contextual actions on page change
            if (currentActionMode != null) {
                currentActionMode.finish();
            }
        }
    });
    requireGeodata = pageToOpen == 1;

    final String realGeocode = geocode;
    final String realGuid = guid;
    AndroidRxUtils.networkScheduler.scheduleDirect(new Runnable() {
        @Override
        public void run() {
            search = Geocache.searchByGeocode(realGeocode, StringUtils.isBlank(realGeocode) ? realGuid : null,
                    false, loadCacheHandler);
            loadCacheHandler.sendMessage(Message.obtain());
        }
    });

    // Load Generic Trackables
    if (StringUtils.isNotBlank(geocode)) {
        AndroidRxUtils.bindActivity(this,
                // Obtain the active connectors and load trackables in parallel.
                Observable.fromIterable(ConnectorFactory.getGenericTrackablesConnectors())
                        .flatMap(new Function<TrackableConnector, Observable<Trackable>>() {
                            @Override
                            public Observable<Trackable> apply(final TrackableConnector trackableConnector) {
                                processedBrands.add(trackableConnector.getBrand());
                                return Observable.defer(new Callable<Observable<Trackable>>() {
                                    @Override
                                    public Observable<Trackable> call() {
                                        return Observable
                                                .fromIterable(trackableConnector.searchTrackables(geocode));
                                    }
                                }).subscribeOn(AndroidRxUtils.networkScheduler);
                            }
                        }).toList())
                .subscribe(new Consumer<List<Trackable>>() {
                    @Override
                    public void accept(final List<Trackable> trackables) {
                        // Todo: this is not really a good method, it may lead to duplicates ; ie: in OC connectors.
                        // Store trackables.
                        genericTrackables.addAll(trackables);
                        if (!trackables.isEmpty()) {
                            // Update the UI if any trackables were found.
                            notifyDataSetChanged();
                        }
                    }
                });
    }

    locationUpdater = new CacheDetailsGeoDirHandler(this);

    // If we have a newer Android device setup Android Beam for easy cache sharing
    AndroidBeam.enable(this, this);
}

From source file:com.if3games.chessonline.DroidFish.java

/** Called when the activity is first created. */
@Override//  w  ww  .  j a va2  s .com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int isGMS = getIntent().getExtras().getInt("gms");
    if (isGMS != 1) {
        isSinglePlayer = true;
    } else {
        isSinglePlayer = false;

        GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this);
        builder.addApi(Games.API).addApi(Plus.API).addApi(AppStateManager.API).addScope(Games.SCOPE_GAMES)
                .addScope(Plus.SCOPE_PLUS_LOGIN).addScope(AppStateManager.SCOPE_APP_STATE);
        mClient = builder.build();

        loadLocal();

        if (isSignedIn()) {
            //onFetchPlayerScoreAndAchive();
            //displayPlayerNameScoreRank();
            //Toast.makeText(this, "I Connected", Toast.LENGTH_SHORT).show();
        }
    }

    Pair<String, String> pair = getPgnOrFenIntent();
    String intentPgnOrFen = pair.first;
    String intentFilename = pair.second;

    createDirectories();

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    settings = PreferenceManager.getDefaultSharedPreferences(this);
    settings.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
            try {
                handlePrefsChange();
            } catch (Exception e) {
                // TODO: handle exception
            }
        }
    });

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    setWakeLock(false);
    wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "droidfish");
    wakeLock.setReferenceCounted(false);

    custom1ButtonActions = new ButtonActions("custom1", CUSTOM1_BUTTON_DIALOG, R.string.select_action);
    custom2ButtonActions = new ButtonActions("custom2", CUSTOM2_BUTTON_DIALOG, R.string.select_action);
    custom3ButtonActions = new ButtonActions("custom3", CUSTOM3_BUTTON_DIALOG, R.string.select_action);

    figNotation = Typeface.createFromAsset(getAssets(), "fonts/DroidFishChessNotationDark.otf");
    setPieceNames(PGNOptions.PT_LOCAL);
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    initUI();

    gameTextListener = new PgnScreenText(pgnOptions);
    if (ctrl != null)
        ctrl.shutdownEngine();
    ctrl = new DroidChessController(this, gameTextListener, pgnOptions);
    egtbForceReload = true;
    readPrefs();
    TimeControlData tcData = new TimeControlData();
    tcData.setTimeControl(timeControl, movesPerSession, timeIncrement);
    if (isSinglePlayer) {
        myTurn = true;
        ctrl.newGame(gameMode, tcData);
        {
            byte[] data = null;
            int version = 1;
            if (savedInstanceState != null) {
                data = savedInstanceState.getByteArray("gameState");
                version = savedInstanceState.getInt("gameStateVersion", version);
            } else {
                String dataStr = settings.getString("gameState", null);
                version = settings.getInt("gameStateVersion", version);
                if (dataStr != null)
                    data = strToByteArr(dataStr);
            }
            if (data != null)
                ctrl.fromByteArray(data, version);
        }
        ctrl.setGuiPaused(true);
        ctrl.setGuiPaused(false);
        ctrl.startGame();
        //startNewGame(0);
        if (intentPgnOrFen != null) {
            try {
                ctrl.setFENOrPGN(intentPgnOrFen);
                setBoardFlip(true);
            } catch (ChessParseError e) {
                // If FEN corresponds to illegal chess position, go into edit board mode.
                try {
                    TextIO.readFEN(intentPgnOrFen);
                } catch (ChessParseError e2) {
                    if (e2.pos != null)
                        startEditBoard(intentPgnOrFen);
                }
            }
        } else if (intentFilename != null) {
            if (intentFilename.toLowerCase(Locale.US).endsWith(".fen")
                    || intentFilename.toLowerCase(Locale.US).endsWith(".epd"))
                loadFENFromFile(intentFilename);
            else
                loadPGNFromFile(intentFilename);
        }
    } else {
        int rnd = new Random().nextInt(2);
        startMultiplayerGameMode(rnd);
    }
}

From source file:com.otaupdater.OTAUpdaterActivity.java

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

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);//from  w  w  w .  j av a2  s .c  om

    if (!cfg.hasProKey()) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                billingSrvConn = new ServiceConnection() {
                    @Override
                    public void onServiceDisconnected(ComponentName name) {
                        billingSrvConn = null;
                    }

                    @Override
                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder);

                        try {
                            Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null);
                            ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                            ArrayList<String> ownedItemData = owned
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                            if (ownedItems != null && ownedItemData != null) {
                                for (int q = 0; q < ownedItems.size(); q++) {
                                    if (ownedItems.get(q).equals(Config.PROKEY_SKU)) {
                                        JSONObject itemData = new JSONObject(ownedItemData.get(q));
                                        cfg.setKeyPurchaseToken(itemData.getString("purchaseToken"));
                                        break;
                                    }
                                }
                            }
                        } catch (RemoteException ignored) {
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        unbindService(this);
                        billingSrvConn = null;
                    }
                }, Context.BIND_AUTO_CREATE);
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.alert_unsupported_title);
        builder.setMessage(R.string.alert_unsupported_message);
        builder.setCancelable(false);
        builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cfg.setIgnoredUnsupportedWarn(true);
                dialog.dismiss();
            }
        });

        final AlertDialog dlg = builder.create();

        dlg.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                onDialogShown(dlg);
            }
        });
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                onDialogClosed(dlg);
            }
        });
        dlg.show();
    }

    setContentView(R.layout.main);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate())
        kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class);

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
            cfg.getStoredKernelUpdate().showUpdateNotif(this);
        }

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}