List of usage examples for android.app ActionBar addTab
@Deprecated public abstract void addTab(Tab tab);
From source file:com.example.android.bluepayandroidsdk.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* w w w . j a va 2s . com*/ public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { if (i == 0) { actionBar.addTab(actionBar.newTab().setText("Run Payment").setTabListener(this)); } else if (i == 1) { actionBar.addTab(actionBar.newTab().setText("Store Token").setTabListener(this)); } else if (i == 2) { actionBar.addTab(actionBar.newTab().setText("Swipe Card").setTabListener(this)); } else { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } } }
From source file:app.screen.MyActivity.java
/** * For more info on using view pager and tabs and action bar, <a href="http://goo.gl/7CsM9">checkout this article</a> * in the Android developer site's "Training" section. * <p/>//from w ww . j a v a 2s.c o m * For more info on ViewPager, <a href="http://goo.gl/NgCUO">read this article</a>. */ private void _setupFragments() { // set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // create the FragmentPagerAdapter FragmentPagerAdapter fragmentPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { try { return Fragments.values()[position].aClass.getConstructor(MyActivity.class) .newInstance(MyActivity.this); } catch (Exception e) { AndroidUtils.logErr(IconPaths.MyApp, "MyActivity - problem creating fragments", e); // something has gone wrong - this shouldn't happen return new Fragment() { /** make a fragment to house {@link R.layout#error_fragment} */ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return super.onCreateView(inflater, container, savedInstanceState); } }; } } @Override public int getCount() { return Fragments.values().length; } public CharSequence getPageTitle(int position) { try { return Fragments.values()[position].title; } catch (Exception e) { return "N/A"; } } }; // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setOffscreenPageLimit(Fragments.values().length); // keep all the pages in memory viewPager.setAdapter(fragmentPagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { /** * When swiping between different app sections, select the corresponding tab. * We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab. */ @Override public void onPageSelected(int position) { super.onPageSelected(position); actionBar.setSelectedNavigationItem(position); } }); // create TabListener ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction transaction) { viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction transaction) { } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction transaction) { } }; // setup tabs for (int i = 0; i < fragmentPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(fragmentPagerAdapter.getPageTitle(i)).setTabListener(tabListener)); } }
From source file:com.idevity.card.read.ReadMain.java
/** * Method onCreate./* ww w . j a v a 2s.c om*/ * * @param savedInstanceState * Bundle */ @TargetApi(19) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_read_main); /* * We will take over the NFC Interface while in the foreground so there * is no additional read attempt. * * If on KitKat, we will set a filter and ignore any callbacks. */ /****************** Initialize NFC ******************/ if (debug) { Log.d(TAG, "Getting Adaptor..."); } NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); /* * Platform version specific handling: KitKat */ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { if (debug) { Log.d(TAG, "Setting Adaptor up for KitKat"); } ReaderCallback listener = new ReaderCallback() { public void onTagDiscovered(Tag tag) { /* * Discard the tags here */ tag = null; } }; int flags = NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK | NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS; adapter.enableReaderMode(this, listener, flags, null); } // Get preferences / settings that have been saved // get the show log this.sharedPref = PreferenceManager.getDefaultSharedPreferences(this); boolean showLog = this.sharedPref.getBoolean(g.getShowLog(), false); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager(), this.sharedPref); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is // no hierarchical // parent. actionBar.setHomeButtonEnabled(true); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener // for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select // the corresponding tab. // We can also use ActionBar.Tab#select() to do this if // we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); /* * Use the following to determine content to show in the tabs. First, * check to see if there is an active intent Also, check to see if there * is an active saved instance state If, active intent - use active * intent; if active intent = null, and saved instance state !null, use * saved instance state; else return user to "main" instructions */ boolean hasIntent = false; boolean hasSavedData = false; try { if (getIntent().getExtras().getByteArray(g.getCardData()) != null) { hasIntent = true; } } catch (Throwable e) { Log.e(TAG, "Error: intent " + e.getMessage()); } try { if (g.getCard() != null) { hasSavedData = true; } } catch (Throwable e) { Log.e(TAG, "Error: saved instance state " + e.getMessage()); } // if intent, populate the variables with the intent values // else if saved instance, populate the same variables with the saved // instance state // else return user to read800-73 activity to read a new card if (hasIntent) { logStringBuffer = getIntent().getExtras().getString(g.getReaderLog()); byte[] _data = getIntent().getExtras().getByteArray(g.getCardData()); this.carddata = new CardData80073(_data); if (debug) { Log.d(TAG, "Using new card data"); } g.putCard(carddata.toByteArray()); g.putLogData(logStringBuffer); } else if (hasSavedData) { logStringBuffer = g.getLogData(); byte[] _data = g.getCard(); this.carddata = new CardData80073(_data); Log.e(TAG, "Using saved card data"); } else { Intent returnuser = new Intent(this, Read80073.class); startActivity(returnuser); Log.e(TAG, "No card data found; returning user to read a new card."); } /* * For each of the sections in the app, add a tab to the action bar. */ Tab tabA = actionBar.newTab(); tabA.setText(getString(R.string.TabRead_Title)); tabA.setTabListener(this); actionBar.addTab(tabA); // this one will become the CAK tab Tab tabB = actionBar.newTab(); tabB.setText(getString(R.string.TabCert_Title)); tabB.setTabListener(this); actionBar.addTab(tabB); // this one will become the CHUID tab Tab tabC = actionBar.newTab(); tabC.setText(getString(R.string.TabChuid_Title)); tabC.setTabListener(this); actionBar.addTab(tabC); // this one will become the APDU log tab // only set up the tab is the preferences for Show Log = True if (showLog) { Tab tabD = actionBar.newTab(); tabD.setText(getString(R.string.TabLog_Title)); tabD.setTabListener(this); actionBar.addTab(tabD); } }
From source file:se.dxapps.generic.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar = getActionBar(); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); mTitle = mDrawerTitle = getTitle();/*from ww w . ja v a 2 s . c om*/ mPlanetTitles = getResources().getStringArray(R.array.planets_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mPlanetTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); // if (savedInstanceState == null) { // selectItem(0); // } //ViewPager stuff. // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.android.cardreader.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.alternate_main_fragment); //TODO Stop Executing Eden //Globals.executeEden(); getUsers(1);//from w w w . j a va 2s . c o m instance = this; final ActionBar actionBar = getActionBar(); actionBar.setTitle(" TartanHacks"); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg)); actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg)); actionBar.setDisplayShowHomeEnabled(true); frags.add(new PersonListFrag(Globals.pending)); frags.add(new PersonListFrag(Globals.allUsers)); frags.add(new PersonListFrag(Globals.checkedIn)); mAdapter = new FragmentAdapter(getFragmentManager()); fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View dialogView = View.inflate(instance, R.layout.dialog_signup, null); idField = (EditText) dialogView.findViewById(R.id.andrewIdField); pb = (ProgressBar) dialogView.findViewById(R.id.progress); nameField = (TextView) dialogView.findViewById(R.id.name); scanView = (TextView) dialogView.findViewById(R.id.scan_view); idField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String id = s.toString(); pb.setVisibility(View.VISIBLE); queryId(id); } @Override public void afterTextChanged(Editable s) { } }); AlertDialog.Builder builder; builder = new AlertDialog.Builder(instance); builder.setView(dialogView); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Globals.adding = false; } }); signupDialog = builder.show(); } }); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(0); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this)); mLoyaltyCardReader = new LoyaltyCardReader(this); // Disable Android Beam and register our card reader callback enableReaderMode(); new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor()); }
From source file:com.wbrenna.gtfsoffline.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }// w ww . ja va 2 s . co m mProgress = (ProgressBar) findViewById(R.id.progress); //read in the preferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); Set<String> emptyString = new HashSet<String>(); emptyString.clear(); Set<String> initial_preferences = mPrefs.getStringSet(getString(R.string.pref_dbs), emptyString); mDBListPrefsOld = initial_preferences; //this is the list of currently checked databases String[] tmpDBActive = initial_preferences.toArray(new String[initial_preferences.size()]); //we have to be careful to exclude databases that aren't in our directory dbHelper = new DatabaseHelper(this); dbHelper.gatherFiles(); mDBList = dbHelper.GetListofDB(); List<String> workingDBList = new ArrayList<String>(); for (int i = 0; i < tmpDBActive.length; i++) { if (mDBList.contains(tmpDBActive[i])) { workingDBList.add(tmpDBActive[i]); } else { initial_preferences.remove(tmpDBActive[i]); } } if (workingDBList.size() == 0) { mDBActive = null; } else { mDBActive = workingDBList.toArray(new String[workingDBList.size()]); } Editor prefsDBEditor = mPrefs.edit(); prefsDBEditor.putStringSet(getString(R.string.pref_dbs), initial_preferences); prefsDBEditor.commit(); //Set up the location management mLocationHelper = new LocationHelper(this); mLocation = mLocationHelper.startLocationManager(); // Define a listener that responds to location updates locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { if (mLocationHelper.isBetterLocation(location, mLocation)) { mLocation = location; if (mLocation != null) { //new ProcessBusStops().execute(); mSectionsPagerAdapter.notifyDataSetChanged(); } else { Toast.makeText(getBaseContext(), R.string.last_location_fix, Toast.LENGTH_LONG).show(); //Log.e(TAG, "No more location fixes "); } } } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } }; //TODO: eventually add automated downloading of databases... // Create the adapter that will return a fragment for each of the // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.android.lightcontrol.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getApplicationContext();// ww w. j av a 2s.co m mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } if (mBluetoothAdapter.isEnabled()) { mChatService = new BluetoothChatService(this, mHandler); } mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); assert actionBar != null; actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (B) { B = false; Toast.makeText(MainActivity.this, "Round theme cancelled", Toast.LENGTH_SHORT).show(); } if (position == 0) { } if (position == 1) { updatespinner(); setupChat(); } if (position == 2) { } if (position == 3) { setupGroupMode(); } actionBar.setSelectedNavigationItem(position); } }); /*for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab(actionBar.newTab() .setText(mAppSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); }*/ actionBar.addTab(actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(0)).setTabListener(this) .setIcon(R.drawable.btn_group_control_icon)); actionBar.addTab(actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(1)).setTabListener(this) .setIcon(R.drawable.btn_light_control_icon)); actionBar.addTab(actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(2)).setTabListener(this) .setIcon(R.drawable.btn_group_configure_icon)); actionBar.addTab(actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(3)).setTabListener(this) .setIcon(R.drawable.btn_sceario_control_icon)); }
From source file:com.vonglasow.michael.satstat.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); defaultUEH = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { Context c = getApplicationContext(); File dumpDir = c.getExternalFilesDir(null); File dumpFile = new File(dumpDir, "satstat-" + System.currentTimeMillis() + ".log"); PrintStream s;//from w ww. j a va 2s . co m try { InputStream buildInStream = getResources().openRawResource(R.raw.build); s = new PrintStream(dumpFile); s.append("SatStat build: "); int i; try { i = buildInStream.read(); while (i != -1) { s.write(i); i = buildInStream.read(); } buildInStream.close(); } catch (IOException e1) { e1.printStackTrace(); } s.append("\n\n"); e.printStackTrace(s); s.flush(); s.close(); } catch (FileNotFoundException e2) { e2.printStackTrace(); } defaultUEH.uncaughtException(t, e); } }); mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); mSharedPreferences.registerOnSharedPreferenceChangeListener(this); final ActionBar actionBar = getActionBar(); setContentView(R.layout.activity_main); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Find out default screen orientation Configuration config = getResources().getConfiguration(); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); int rot = wm.getDefaultDisplay().getRotation(); isWideScreen = (config.orientation == Configuration.ORIENTATION_LANDSCAPE && (rot == Surface.ROTATION_0 || rot == Surface.ROTATION_180) || config.orientation == Configuration.ORIENTATION_PORTRAIT && (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270)); Log.d("MainActivity", "isWideScreen=" + Boolean.toString(isWideScreen)); // compact action bar int dpX = (int) (this.getResources().getDisplayMetrics().widthPixels / this.getResources().getDisplayMetrics().density); /* * This is a crude way to ensure a one-line action bar with tabs * (not a drop-down list) and home (incon) and title only if there * is space, depending on screen width: * divide screen in units of 64 dp * each tab requires 1 unit, home and menu require slightly less, * title takes up approx. 2.5 units in portrait, * home and title are about 2 units wide in landscape */ if (dpX < 192) { // just enough space for drop-down list and menu actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); } else if (dpX < 320) { // not enough space for four tabs, but home will fit next to list actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } else if (dpX < 384) { // just enough space for four tabs actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); } else if ((dpX < 448) || ((config.orientation == Configuration.ORIENTATION_PORTRAIT) && (dpX < 544))) { // space for four tabs and home, but not title actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowTitleEnabled(false); } else { // ample space for home, title and all four tabs actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowTitleEnabled(true); } setEmbeddedTabs(actionBar, true); providerLocations = new HashMap<String, Location>(); mAvailableProviderStyles = new ArrayList<String>(Arrays.asList(LOCATION_PROVIDER_STYLES)); providerStyles = new HashMap<String, String>(); providerAppliedStyles = new HashMap<String, String>(); providerInvalidationHandler = new Handler(); providerInvalidators = new HashMap<String, Runnable>(); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(this); // Add tabs, specifying the tab's text and TabListener for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar.addTab(actionBar.newTab() //.setText(mSectionsPagerAdapter.getPageTitle(i)) .setIcon(mSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } // This is needed by the mapsforge library. AndroidGraphicFactory.createInstance(this.getApplication()); // Get system services for event delivery mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mOrSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); mAccSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mGyroSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); mMagSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mLightSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); mProximitySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); mPressureSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE); mHumiditySensor = mSensorManager.getDefaultSensor(Sensor.TYPE_RELATIVE_HUMIDITY); mTempSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_AMBIENT_TEMPERATURE); mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); mAccSensorRes = getSensorDecimals(mAccSensor, mAccSensorRes); mGyroSensorRes = getSensorDecimals(mGyroSensor, mGyroSensorRes); mMagSensorRes = getSensorDecimals(mMagSensor, mMagSensorRes); mLightSensorRes = getSensorDecimals(mLightSensor, mLightSensorRes); mProximitySensorRes = getSensorDecimals(mProximitySensor, mProximitySensorRes); mPressureSensorRes = getSensorDecimals(mPressureSensor, mPressureSensorRes); mHumiditySensorRes = getSensorDecimals(mHumiditySensor, mHumiditySensorRes); mTempSensorRes = getSensorDecimals(mTempSensor, mTempSensorRes); networkTimehandler = new Handler(); networkTimeRunnable = new Runnable() { @Override public void run() { int newNetworkType = mTelephonyManager.getNetworkType(); if (getNetworkGeneration(newNetworkType) != mLastNetworkGen) onNetworkTypeChanged(newNetworkType); else networkTimehandler.postDelayed(this, NETWORK_REFRESH_DELAY); } }; wifiTimehandler = new Handler(); wifiTimeRunnable = new Runnable() { @Override public void run() { mWifiManager.startScan(); wifiTimehandler.postDelayed(this, WIFI_REFRESH_DELAY); } }; updateLocationProviderStyles(); }