Example usage for android.app ActionBar NAVIGATION_MODE_TABS

List of usage examples for android.app ActionBar NAVIGATION_MODE_TABS

Introduction

In this page you can find the example usage for android.app ActionBar NAVIGATION_MODE_TABS.

Prototype

int NAVIGATION_MODE_TABS

To view the source code for android.app ActionBar NAVIGATION_MODE_TABS.

Click Source Link

Document

Tab navigation mode.

Usage

From source file:com.idevity.card.read.ReadMain.java

/**
 * Method onCreate./*from w w  w.j av  a  2 s.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:org.xwalk.core.xwview.shell.XWalkViewShellActivity.java

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

    registerTracingReceiverWhenIdle();/*from  ww  w.  java  2  s.  co m*/

    if (!CommandLine.isInitialized()) {
        CommandLine.initFromFile(COMMAND_LINE_FILE);
        String[] commandLineParams = getCommandLineParamsFromIntent(getIntent());
        if (commandLineParams != null) {
            CommandLine.getInstance().appendSwitchesAndArguments(commandLineParams);
        }
    }

    waitForDebuggerIfNeeded();

    setContentView(R.layout.testshell_activity);

    mActionBar = getActionBar();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mSectionsPagerAdapter = new SectionsPagerAdapter(this, getSupportFragmentManager(), mActionBar);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            mActionBar.setSelectedNavigationItem(position);
        }
    });

    mProgressMap = new HashMap<XWalkView, Integer>();
    // Add two tabs.
    mActionBar.addTab(mActionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(0)).setTabListener(this));
    mActionBar.addTab(mActionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(1)).setTabListener(this));

    mToolbar = (LinearLayout) findViewById(R.id.toolbar);
    mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground();

    IntentFilter intentFilter = new IntentFilter(ACTION_LAUNCH_URL);
    mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Bundle bundle = intent.getExtras();
            if (bundle == null)
                return;

            if (bundle.containsKey("url")) {
                String extra = bundle.getString("url");
                if (mActiveView != null)
                    mActiveView.load(sanitizeUrl(extra), null);
            }
        }
    };
    registerReceiver(mReceiver, intentFilter);
}

From source file:com.whitespider.impact.ble.sensortag.ViewPagerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(mResourceFragmentPager);

    // Set up the action bar
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ImageView view = (ImageView) findViewById(android.R.id.home);
    //view.setPadding(10, 0, 20, 10);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(mResourceIdPager);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from  w w  w.  j a  va 2 s . c  om
        public void onPageSelected(int n) {
            // Log.d(TAG, "onPageSelected: " + n);
            actionBar.setSelectedNavigationItem(n);
        }
    });
    // Create the adapter that will return a fragment for each section
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager.setAdapter(mSectionsPagerAdapter);

    this.getActionBar().setDisplayShowTitleEnabled(false);
    this.getActionBar().setDisplayShowHomeEnabled(false);

    this.busyDialog = new Dialog(this);
    this.busyDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    ;
    this.busyDialog.setContentView(R.layout.frame_progress);
    this.progressBarTextView = (TextView) this.busyDialog.findViewById(R.id.progressTextView);
}

From source file:de.WyLight.WyLight.WiflyControlActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (null != savedInstanceState) {
        mARGB = savedInstanceState.getInt(STATE_KEY_COLOR, 0xffffffff);
        Color.colorToHSV(mARGB, mHSV);
    }//from   w  w w  .jav  a2  s  .c om

    setContentView(R.layout.view_pager);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowTitleEnabled(false);

    final ViewPager pager = (ViewPager) findViewById(R.id.pager);
    final WiflyPagerAdapter adapter = new WiflyPagerAdapter(getFragmentManager());
    pager.setAdapter(adapter);
    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            /* not implemented */
        }

        public void onPageScrollStateChanged(int arg0) {
            /* not implemented */
        }

        public void onPageSelected(int arg0) {
            getActionBar().setSelectedNavigationItem(arg0);
            mFragments[arg0].onShow(mMenu);
        }
    });

    TabListener listener = new TabListener(pager);
    for (int i = 0; i < pager.getAdapter().getCount(); ++i) {
        Tab tab = actionBar.newTab().setIcon(mFragments[i].getIcon()).setTabListener(listener);
        actionBar.addTab(tab);
    }

    Intent i = getIntent();
    mRemote = (Endpoint) i.getSerializableExtra(EXTRA_ENDPOINT);
}

From source file:com.f8full.casserolesencours.CasserolesEnCoursV2.java

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

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from w w  w. j  ava 2s. c om*/
        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++) {
        // 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 callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    try {
        // initialize the transport
        httpTransport = new NetHttpTransport();

        // authorization
        //Credential credential = new Credential();

        // set up global Fusiontables instance
        client = new Fusiontables.Builder(httpTransport, JSON_FACTORY, null)
                .setApplicationName(APPLICATION_NAME).build();

        //System.out.println("Success! Now add code here.");
        String fromTableID = "1cmlx9aChHUYTWwYivaZucr7NHNsP_ulvEPX1FoM";

        Sql sql = client.query().sql("SELECT * FROM " + fromTableID);

        new ViewerSetupTask().execute(sql);

    } catch (IOException e) {
        System.err.println(e.getMessage());
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:app.umitems.greenclock.DeskClock.java

private void createTabs(int selectedIndex) {
    mActionBar = getActionBar();/*from  w  ww  . ja v  a  2s.c o m*/

    if (mActionBar != null) {
        mActionBar.setDisplayOptions(0);
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        mAlarmTab = mActionBar.newTab();
        mAlarmTab.setIcon(R.drawable.alarm_tab);
        mAlarmTab.setContentDescription(R.string.menu_alarm);
        mTabsAdapter.addTab(mAlarmTab, AlarmClockFragment.class, ALARM_TAB_INDEX);

        mClockTab = mActionBar.newTab();
        mClockTab.setIcon(R.drawable.clock_tab);
        mClockTab.setContentDescription(R.string.menu_clock);
        mTabsAdapter.addTab(mClockTab, ClockFragment.class, CLOCK_TAB_INDEX);

        mTimerTab = mActionBar.newTab();
        mTimerTab.setIcon(R.drawable.timer_tab);
        mTimerTab.setContentDescription(R.string.menu_timer);
        mTabsAdapter.addTab(mTimerTab, TimerFragment.class, TIMER_TAB_INDEX);

        mStopwatchTab = mActionBar.newTab();
        mStopwatchTab.setIcon(R.drawable.stopwatch_tab);
        mStopwatchTab.setContentDescription(R.string.menu_stopwatch);
        mTabsAdapter.addTab(mStopwatchTab, StopwatchFragment.class, STOPWATCH_TAB_INDEX);

        mActionBar.setSelectedNavigationItem(selectedIndex);
        mTabsAdapter.notifySelectedPage(selectedIndex);
    }
}

From source file:com.codebutler.farebot.activity.AdvancedCardInfoActivity.java

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

    findViewById(R.id.error_button).setOnClickListener(new View.OnClickListener() {
        @Override/*from   w w w . j a  v a 2s .c om*/
        public void onClick(View v) {
            reportError();
        }
    });

    Serializer serializer = FareBotApplication.getInstance().getSerializer();
    mCard = Card.fromXml(serializer, getIntent().getStringExtra(AdvancedCardInfoActivity.EXTRA_CARD));

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabPagerAdapter(this, viewPager);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mCard.getCardType().toString() + " " + Utils.getHexString(mCard.getTagId(), "<error>"));

    if (mCard.getScannedAt().getTime() > 0) {
        String date = Utils.dateFormat(mCard.getScannedAt());
        String time = Utils.timeFormat(mCard.getScannedAt());
        actionBar.setSubtitle(Utils.localizeString(R.string.scanned_at_format, time, date));
    }

    if (getIntent().hasExtra(EXTRA_ERROR)) {
        mError = (Exception) getIntent().getSerializableExtra(EXTRA_ERROR);
        if (mError instanceof UnsupportedCardException) {
            findViewById(R.id.unknown_card).setVisibility(View.VISIBLE);
        } else if (mError instanceof UnauthorizedException) {
            findViewById(R.id.unauthorized_card).setVisibility(View.VISIBLE);
            findViewById(R.id.load_keys).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(new Intent(AdvancedCardInfoActivity.this, AddKeyActivity.class));
                }
            });
        } else {
            findViewById(R.id.error).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.error_text)).setText(Utils.getErrorMessage(mError));
        }
    }

    CardHasManufacturingInfo infoAnnotation = mCard.getClass().getAnnotation(CardHasManufacturingInfo.class);
    if (infoAnnotation == null || infoAnnotation.value()) {
        mTabsAdapter.addTab(actionBar.newTab().setText(R.string.hw_detail), CardHWDetailFragment.class,
                getIntent().getExtras());
    }

    CardRawDataFragmentClass annotation = mCard.getClass().getAnnotation(CardRawDataFragmentClass.class);
    if (annotation != null) {
        Class rawDataFragmentClass = annotation.value();
        if (rawDataFragmentClass != null) {
            mTabsAdapter.addTab(actionBar.newTab().setText(R.string.data), rawDataFragmentClass,
                    getIntent().getExtras());
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        }
    }
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.Main.java

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

    {/* w ww .  jav a 2  s  .c o m*/
        // Use intent in case the app was started by another app to send messages/images
        Intent intent = getIntent();
        if (intent != null) {
            Uri data = intent.getData();
            if (intent.getType() != null) {
                // Figure out what to do based on the intent type
                if (intent.getType().contains("image/")) {
                    // Handle intents with image data ...

                    // should probably set here a window only to select contact destination

                    // Create intent to deliver some kind of result data
                    //Intent result = new Intent("net.ddp2p.RESULT_ACTION", Uri.parse("content://result_uri"));
                    // setResult(Activity.RESULT_OK, result);
                    setResult(Activity.RESULT_CANCELED);
                    finish();
                } else if (intent.getType().equals("text/plain")) {
                    // Handle intents with text ...

                    // should probably set here a window only to select contact destination

                    // Create intent to deliver some kind of result data
                    //Intent result = new Intent("net.ddp2p.RESULT_ACTION", Uri.parse("content://result_uri"));
                    // setResult(Activity.RESULT_OK, result);
                    setResult(Activity.RESULT_CANCELED);
                    finish();
                }
            }
        }
    }

    setContentView(R.layout.main);

    //initial action bar
    actionBar = this.getActionBar();

    //set tab navigation mode
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    //initial view pager
    mViewPager = (ViewPager) this.findViewById(R.id.pager);

    actionBar.setDisplayHomeAsUpEnabled(false);

    //add adapter
    mAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager());

    mViewPager.setAdapter(mAdapter);

    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // if (position > 1) position = 1;
            actionBar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }

    });

    //add tabs
    actionBar.addTab(actionBar.newTab().setText(Util.__("Connections")).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(Util.__("Organizations")).setTabListener(this));
    if (PAGES_NB > 2) {
        actionBar.addTab(actionBar.newTab().setText("Acts").setTabListener(this));
    }

    new net.ddp2p.common.util.DDP2P_ServiceThread("loading icons", false, this) {
        @Override
        public void _run() {
            Main m = (Main) ctx;
            Bitmap bmp = PhotoUtil.decodeSampledBitmapFromResource(getResources(),
                    R.drawable.organization_default_img, 55, 55);
            icon_org = PhotoUtil.BitmapToByteArray(bmp, 100);
        }
    }.start();
}

From source file:be.brunoparmentier.openbikesharing.app.activities.StationsListActivity.java

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

    viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override//from   w w  w  . ja va2 s  .c om
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    stationsDataSource = new StationsDataSource(this);
    stations = stationsDataSource.getStations();
    favStations = stationsDataSource.getFavoriteStations();

    actionBar = getActionBar();
    actionBar.addTab(actionBar.newTab().setText(getString(R.string.all_stations)).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(getString(R.string.favorite_stations)).setTabListener(this));
    actionBar.setHomeButtonEnabled(false);

    settings = PreferenceManager.getDefaultSharedPreferences(this);
    boolean firstRun = settings.getString(PREF_KEY_NETWORK_ID, "").isEmpty();

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    tabsPagerAdapter = new TabsPagerAdapter(getSupportFragmentManager());
    viewPager.setAdapter(tabsPagerAdapter);

    setDBLastUpdateText();

    if (firstRun) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.welcome_dialog_message);
        builder.setTitle(R.string.welcome_dialog_title);
        builder.setPositiveButton(R.string.welcome_dialog_ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(StationsListActivity.this, BikeNetworksListActivity.class);
                startActivityForResult(intent, PICK_NETWORK_REQUEST);
            }
        });
        builder.setNegativeButton(R.string.welcome_dialog_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        AlertDialog dialog = builder.create();
        dialog.show();
    } else {
        if (savedInstanceState != null) {
            bikeNetwork = (BikeNetwork) savedInstanceState.getSerializable("bikeNetwork");
            stations = (ArrayList<Station>) savedInstanceState.getSerializable("stations");
            favStations = (ArrayList<Station>) savedInstanceState.getSerializable("favStations");
        } else {
            String networkId = settings.getString(PREF_KEY_NETWORK_ID, "");
            String stationUrl = BASE_URL + "/" + networkId;
            new JSONDownloadTask().execute(stationUrl);
        }
    }
}

From source file:com.hardcopy.retroband.MainActivity.java

/*****************************************************
 * Overrided methods/*from  w ww .  j a v a 2 s  .  c  o  m*/
 ******************************************************/

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

    // ----- System, Context
    mContext = this;// .getApplicationContext();
    mActivityHandler = new ActivityHandler();
    AppSettings.initializeAppSettings(mContext);

    setContentView(R.layout.activity_main);

    // Load static utilities
    mUtils = new Utils(mContext);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the
    // primary sections of the app.
    mFragmentManager = getSupportFragmentManager();
    mSectionsPagerAdapter = new LLFragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab.
    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++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // Setup views
    mImageBT = (ImageView) findViewById(R.id.status_title);
    mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible));
    mTextStatus = (TextView) findViewById(R.id.status_text);
    mTextStatus.setText(getResources().getString(R.string.bt_state_init));

    // Do data initialization after service started and binded
    doStartService();
}