List of usage examples for android.content.res Configuration SCREENLAYOUT_SIZE_LARGE
int SCREENLAYOUT_SIZE_LARGE
To view the source code for android.content.res Configuration SCREENLAYOUT_SIZE_LARGE.
Click Source Link
From source file:com.adjust.sdk.Util.java
private static String getScreenSize(final int screenLayout) { final int screenSize = screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (screenSize) { case Configuration.SCREENLAYOUT_SIZE_SMALL: return SMALL; case Configuration.SCREENLAYOUT_SIZE_NORMAL: return NORMAL; case Configuration.SCREENLAYOUT_SIZE_LARGE: return LARGE; case 4://w ww . j a v a 2s . c om return XLARGE; default: return UNKNOWN; } }
From source file:com.owncloud.android.ui.activity.FileDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFile = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); mAccount = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT); mStorageManager = new FileDataStorageManager(mAccount, getContentResolver()); // check if configuration changed to large-land ; for a tablet being changed from portrait to landscape when in FileDetailActivity Configuration conf = getResources().getConfiguration(); mConfigurationChangedToLandscape = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE && (conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE); if (!mConfigurationChangedToLandscape) { setContentView(R.layout.file_activity_details); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { mWaitingToPreview = false;/*from ww w. j a va2 s .c o m*/ createChildFragment(); } else { mWaitingToPreview = savedInstanceState.getBoolean(KEY_WAITING_TO_PREVIEW); } mDownloadConnection = new DetailsServiceConnection(); bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE); mUploadConnection = new DetailsServiceConnection(); bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE); } else { backToDisplayActivity(false); // the 'back' won't be effective until this.onStart() and this.onResume() are completed; } }
From source file:com.grepsound.activities.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar);//from www . jav a2 s . co m mDarkHoverView = findViewById(R.id.dark_hover_view); mDarkHoverView.setAlpha(0); getFragmentManager().addOnBackStackChangedListener(this); fMenu = new PlayerFragment(); mMainFrag = new MyProfileFragment(); getFragmentManager().beginTransaction().replace(R.id.move_to_back_container, mMainFrag) .replace(R.id.left_drawer, fMenu).commit(); int layoutSizeMask = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; mDrawerIsLocked = (layoutSizeMask == Configuration.SCREENLAYOUT_SIZE_LARGE || layoutSizeMask == Configuration.SCREENLAYOUT_SIZE_XLARGE) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; setupNavigationDrawer(mDrawerIsLocked); mAccount = CreateSyncAccount(this); ContentResolver.addPeriodicSync(mAccount, AUTHORITY, new Bundle(), SYNC_INTERVAL); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Log.i(TAG, "wifi only is " + prefs.getBoolean("wifi_only", false)); }
From source file:com.facebook.samples.socialcafe.MenuFragmentActivity.java
public void requestUserData() { Bundle params = new Bundle(); int screenLayoutSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; if (screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_LARGE || screenLayoutSize == Configuration.SCREENLAYOUT_SIZE_XLARGE) { params.putString("fields", "name, picture.type(large)"); } else {/*w w w . j av a2 s . c om*/ params.putString("fields", "name, picture.type(normal)"); } params.putString("fields", "name, picture.type(large)"); ((SocialCafeApplication) getActivity().getApplication()).asyncRunner.request("me", params, new UserDataRequestListener()); }
From source file:com.near.chimerarevo.fragments.PostsRecyclerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.posts_list_layout, container, false); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true;//from w w w.java 2 s. c om } else isLandscapeLarge = false; if (!isLandscapeLarge) ((BaseActivity) getActivity()).getToolbar().getBackground().setAlpha(0); mListView = (RecyclerView) v.findViewById(R.id.cardList); mListView.setOverScrollMode(View.OVER_SCROLL_NEVER); mLoadingBar = (ProgressWheel) v.findViewById(R.id.loading_bar); mFab = (FloatingActionButton) v.findViewById(R.id.floating_action); mFab.setEnabled(false); mHeader = v.findViewById(R.id.header); mHeaderText = (TextView) mHeader.findViewById(R.id.header_title); mHeaderImg = (KenBurnsView) mHeader.findViewById(R.id.header_img); mSwipeRefreshLayout = new SwipeRefreshLayout(container.getContext()); mSwipeRefreshLayout.addView(v, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mSwipeRefreshLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mSwipeRefreshLayout.setOnRefreshListener(this); mSwipeRefreshLayout.setColorSchemeResources(R.color.blue_light, R.color.red_light, R.color.green_light, R.color.orange_light); return mSwipeRefreshLayout; }
From source file:com.bydavy.card.receipts.activities.ReceiptPagerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_receipt_pager); mLoadingView = findViewById(R.id.loading_container); mContentView = findViewById(R.id.content_container); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mReceiptPagerFragment = (ReceiptPagerFragment) getSupportFragmentManager() .findFragmentById(FRAGMENT_PAGER_FRAGMENT_ID); if (mReceiptPagerFragment == null) { final Bundle bundle = getIntent().getExtras(); if (bundle == null) { LogHelper.e(ErrorID.EXTRA_IS_NULL, "Attempt to open " + ReceiptPagerActivity.class.getName() + " without extras in intent", null);// w w w .j a v a2 s . c o m finish(); return; } // Load data from the intent final int index = bundle.getInt(INTENT_BUNDLE_INDEX); final String selection = bundle.getString(INTENT_BUNDLE_CURSOR_SELECTION); final String[] selectionArgs = bundle.getStringArray(INTENT_BUNDLE_CURSOR_SELECTION_ARGS); final String sortOrder = bundle.getString(INTENT_BUNDLE_CURSOR_SORT_ORDER); // Create the fragment mReceiptPagerFragment = ReceiptPagerFragment.newInstance(index, selection, selectionArgs, sortOrder); // Publish the fragment final FragmentTransaction fm = getSupportFragmentManager().beginTransaction(); fm.add(FRAGMENT_PAGER_FRAGMENT_ID, mReceiptPagerFragment); fm.commit(); } mReceiptPagerFragment.setStateListener(this, true); // If Landscape && screen lize >= Large, finish the activity if ((getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) && AndroidUtils.isScreenSizeBiggerOrEqual(getResources(), Configuration.SCREENLAYOUT_SIZE_LARGE)) { setActivityResult(); finish(); } }
From source file:com.raja.knowme.FragmentSpecialization.java
private AppTextView addItem(final SpecializationDetailsObject data) { final AppTextView mTextView = new AppTextView(getActivity()); /* Multiple Screen Size Condition */ // Small Size if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(14);/*from w w w . j ava 2s. c o m*/ mTextView.setPadding(3, 15, 0, 0); } //Normal Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(16); mTextView.setPadding(3, 15, 0, 0); } // Large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(20); mTextView.setPadding(3, 15, 0, 0); } //X-large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(24); mTextView.setPadding(3, 15, 0, 0); } //Undefined Size else { //Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show(); LayoutParams mViewParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSpecializationName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(20); mTextView.setPadding(3, 15, 0, 0); } /*try { mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mImage, 0); } catch (Exception e) { Log.w(this.getClass().getName(), "Drawable not found for : " + name); }*/ if (data.getSpecializationLink().length() > 0) { mTextView.setBackgroundResource(R.drawable.button_config); mTextView.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (data.getSpecializationLink().trim().length() > 0) openWebPage(data.getSpecializationLink(), mTextView); else { mTextView.startAnimation(shake); Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show(); } } }); } return mTextView; }
From source file:com.raja.knowme.FragmentSkills.java
private AppTextView addItem(final SkillsDetailsObject data) { final AppTextView mTextView = new AppTextView(getActivity()); /* Multiple Screen Size Condition */ // Small Size if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_SMALL) { // Toast.makeText(getActivity(), "small", Toast.LENGTH_SHORT).show(); LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSkillsName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(12);/*from ww w .j a v a 2 s. c o m*/ mTextView.setPadding(3, 15, 0, 0); } //Normal Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_NORMAL) { // Toast.makeText(getActivity(), "normal", Toast.LENGTH_SHORT).show(); LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSkillsName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(16); mTextView.setPadding(3, 15, 0, 0); } // Large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) { // Toast.makeText(getActivity(), "large", Toast.LENGTH_SHORT).show(); LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSkillsName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(20); mTextView.setPadding(3, 15, 0, 0); } //X-large Size else if ((getContext().getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE) { // Toast.makeText(getActivity(), "xlarge", Toast.LENGTH_SHORT).show(); LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSkillsName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(24); mTextView.setPadding(3, 15, 0, 0); } //Undefined Size else { // Toast.makeText(getActivity(), "undefined", Toast.LENGTH_SHORT).show(); LinearLayout.LayoutParams mViewParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); mViewParams.setMargins(0, 5, -5, 0); mTextView.setLayoutParams(mViewParams); mTextView.setText(data.getSkillsName()); mTextView.setGravity(Gravity.LEFT); mTextView.setTextColor(Color.WHITE); mTextView.setTextSize(20); mTextView.setPadding(3, 15, 0, 0); } /*try { mTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, mImage, 0); } catch (Exception e) { Log.w(this.getClass().getName(), "Drawable not found for : " + name); }*/ if (data.getSkillsLink().length() > 0) { mTextView.setBackgroundResource(R.drawable.button_config); mTextView.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (data.getSkillsLink().trim().length() > 0) openWebPage(data.getSkillsLink(), mTextView); else { mTextView.startAnimation(shake); Toast.makeText(getActivity(), R.string.error_redirection_link, Toast.LENGTH_SHORT).show(); } } }); } return mTextView; }
From source file:net.gaast.giggity.ScheduleViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (Giggity) getApplication();/*from w w w. jav a 2 s . c o m*/ pref = PreferenceManager.getDefaultSharedPreferences(app); curView = getResources() .getIdentifier(pref.getString("default_view", "net.gaast.giggity:id/block_schedule"), null, null); showHidden = pref.getBoolean("show_hidden", false); /* Consider making this a setting, some may find their tablet too small. */ int screen = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; tabletView = (screen >= Configuration.SCREENLAYOUT_SIZE_LARGE); setContentView(R.layout.schedule_view_activity); View dl = drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); drawer = (RelativeLayout) dl.findViewById(R.id.drawer); drawer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // NOOP at least for now just so touches don't fall through to bigScreen. } }); ViewGroup menu = (LinearLayout) dl.findViewById(R.id.menu); menu.getChildCount(); /* Set event handler for all static buttons, going to the option menu code. Dynamic buttons * (from the schedule) have their own handlers. */ for (int i = 0; i < menu.getChildCount(); ++i) { View btn = menu.getChildAt(i); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Not for now as I can't undo it (toggler not calling handlers?) TODO v.setBackground(getResources().getDrawable(R.drawable.menu_gradient)); onOptionsItemSelectedInt(v.getId()); drawerLayout.closeDrawers(); } }); } if (wantDrawer) { /* Hamburger menu! */ /* Should still consider v7-appcompat, depending on how much it, again, affects apk size.. */ getActionBar().setDisplayHomeAsUpEnabled(true); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_menu_white_24dp, R.string.navdrawer_on, R.string.navdrawer_off) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); /* Looks like this code doesn't actually run BTW. Need to figure that out later. */ updateNavDrawer(); } @Override public void onDrawerClosed(View drawerView) { super.onDrawerClosed(drawerView); invalidateOptionsMenu(); } }; } else { drawerLayout.removeView(drawer); } bigScreen = (LinearLayout) dl.findViewById(R.id.bigScreen); updateOrientation(getResources().getConfiguration().orientation); viewerContainer = (RelativeLayout) dl.findViewById(R.id.viewerContainer); /* TODO: See if I can do this in XML as well? (It's a custom private view.) */ RelativeLayout.LayoutParams lp; lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); days = new DayButtons(this); viewerContainer.addView(days, lp); redraw = false; timer = new Handler(); /* If the OS informs us that the timezone changes, close this activity so the schedule gets reloaded. (This because input is usually TZ-unaware while our objects aren't.) */ tzClose = new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { ScheduleViewActivity.this.finish(); } }; registerReceiver(tzClose, new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED)); if (!getIntent().getAction().equals(Intent.ACTION_VIEW)) return; String url = getIntent().getDataString(); Fetcher.Source fs; if (getIntent().getBooleanExtra("PREFER_CACHED", false)) fs = Fetcher.Source.CACHE_ONLINE; else fs = Fetcher.Source.ONLINE_CACHE; /* I think reminders come in via this activity (instead of straight to itemview) because we may have to reload schedule data? */ if (url.contains("#")) { String parts[] = url.split("#", 2); url = parts[0]; showEventId = parts[1]; } if (app.hasSchedule(url)) { try { sched = app.getSchedule(url, fs); } catch (Exception e) { // Java makes me tired. e.printStackTrace(); } onScheduleLoaded(); } else { loadScheduleAsync(url, fs); } }
From source file:com.near.chimerarevo.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instanceState = savedInstanceState;//from w w w. jav a 2 s . c om if (!getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE).getBoolean("hasTutorialShown", false)) startActivity(new Intent(this, TutorialActivity.class)); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE) isLandscapeLarge = true; } else isLandscapeLarge = false; mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer_list); mFooter = LayoutInflater.from(this).inflate(R.layout.drawer_list_footer, mDrawerList, false); mDrawerList.addFooterView(mFooter); mShadow = findViewById(R.id.drop_shadow); if (!isLandscapeLarge) { mDrawerList.addHeaderView( LayoutInflater.from(this).inflate(R.layout.drawer_list_header, mDrawerList, false), null, false); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) SysUtils.setTopStatusMargin(this, mDrawerLayout); } mDrawerList.setGroupIndicator(null); mDrawerList.setOnGroupClickListener(this); mDrawerList.setOnChildClickListener(this); mDrawerList.setOnGroupExpandListener(this); mMenuAdapter = new MenuAdapter(this); mDrawerList.setAdapter(mMenuAdapter); if (!isLandscapeLarge) { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, getToolbar(), R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); } mFooter.findViewById(R.id.unlock_premium_btn).setVisibility(View.GONE); try { mHelper = new IabHelper(this, Constants.LICENSE_KEY); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { isLicensed = result.isSuccess(); if (isLicensed) mHelper.queryInventoryAsync(MainActivity.this); else SysUtils.toggleAppWidgets(MainActivity.this, false); } }); } catch (Exception e) { e.printStackTrace(); } if (savedInstanceState != null) { prevSelection = savedInstanceState.getByte("prevSelection"); mMenuAdapter.toggleSelection(0); if (prevSelection != 2) mMenuAdapter.toggleSelection(prevSelection); selectMenuItem(prevSelection); } else selectMenuItem(0); }