com.nxp.nfc_demo

## Class MainActivity

- java.lang.Object
- - android.content.Context
  - - android.content.ContextWrapper
    - - android.view.ContextThemeWrapper
      - - android.app.Activity
        - - android.support.v4.app.FragmentActivity
          - - android.support.v4.app.Watson
            - - com.actionbarsherlock.app.SherlockFragmentActivity
              - - com.nxp.nfc_demo.MainActivity

- All Implemented Interfaces:
    android.content.ComponentCallbacks, android.content.ComponentCallbacks2, android.view.KeyEvent.Callback, android.view.LayoutInflater.Factory, android.view.LayoutInflater.Factory2, android.view.View.OnCreateContextMenuListener, android.view.Window.Callback, com.actionbarsherlock.ActionBarSherlock.OnActionModeFinishedListener, com.actionbarsherlock.ActionBarSherlock.OnActionModeStartedListener, com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener, com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener, com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener

      public class MainActivity
      extends com.actionbarsherlock.app.SherlockFragmentActivity

  The main activity of this app, which builds the main gui and processes the commands.
  Version:
    1.0

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class android.support.v4.app.Watson

      `android.support.v4.app.Watson.OnCreateOptionsMenuListener, android.support.v4.app.Watson.OnOptionsItemSelectedListener, android.support.v4.app.Watson.OnPrepareOptionsMenuListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private android.nfc.NfcAdapter` | `mAdapter`
    `private android.widget.TabHost` | `mTabHost`
    `private TabsAdapter` | `mTabsAdapter`
    `private android.support.v4.view.ViewPager` | `mViewPager`
    `private android.app.PendingIntent` | `pendingIntent`
    `private NFCReader` | `reader`
    `private NFCWriter` | `writer`

    - ### Fields inherited from class android.app.Activity

      `DEFAULT_KEYS_DIALER, DEFAULT_KEYS_DISABLE, DEFAULT_KEYS_SEARCH_GLOBAL, DEFAULT_KEYS_SEARCH_LOCAL, DEFAULT_KEYS_SHORTCUT, FOCUSED_STATE_SET, RESULT_CANCELED, RESULT_FIRST_USER, RESULT_OK`

    - ### Fields inherited from class android.content.Context

      `ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_ABOVE_CLIENT, BIND_ADJUST_WITH_ACTIVITY, BIND_ALLOW_OOM_MANAGEMENT, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_IMPORTANT, BIND_NOT_FOREGROUND, BIND_WAIVE_PRIORITY, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DISPLAY_SERVICE, DOWNLOAD_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, INPUT_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MEDIA_ROUTER_SERVICE, MODE_APPEND, MODE_ENABLE_WRITE_AHEAD_LOGGING, MODE_MULTI_PROCESS, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NFC_SERVICE, NOTIFICATION_SERVICE, NSD_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, STORAGE_SERVICE, TELEPHONY_SERVICE, TEXT_SERVICES_MANAGER_SERVICE, UI_MODE_SERVICE, USB_SERVICE, USER_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_P2P_SERVICE, WIFI_SERVICE, WINDOW_SERVICE`

    - ### Fields inherited from interface android.content.ComponentCallbacks2

      `TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MainActivity()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `checkNFC()` Check if a NFC adapter is available and/or activated.
    `private void` | `doProcess(android.content.Intent intent)` This method checks and send the chosen command.
    `protected void` | `onCreate(android.os.Bundle savedInstanceState)` This method builds the main user interface using the TabsAdapter class.
    `protected void` | `onNewIntent(android.content.Intent intent)`
    `void` | `onPause()`
    `void` | `onResume()`
    `protected void` | `sendData(boolean b, android.nfc.Tag tag)` This method simply processes the command sending only from the SendTextFragment.

    - ### Methods inherited from class com.actionbarsherlock.app.SherlockFragmentActivity

      `addContentView, closeOptionsMenu, dispatchKeyEvent, getSherlock, getSupportActionBar, getSupportMenuInflater, invalidateOptionsMenu, onActionModeFinished, onActionModeStarted, onConfigurationChanged, onCreateOptionsMenu, onCreateOptionsMenu, onCreatePanelMenu, onDestroy, onMenuItemSelected, onMenuOpened, onOptionsItemSelected, onOptionsItemSelected, onPanelClosed, onPostCreate, onPostResume, onPrepareOptionsMenu, onPrepareOptionsMenu, onPreparePanel, onRestoreInstanceState, onSaveInstanceState, onStop, onTitleChanged, openOptionsMenu, requestWindowFeature, setContentView, setContentView, setContentView, setSupportProgress, setSupportProgressBarIndeterminate, setSupportProgressBarIndeterminateVisibility, setSupportProgressBarVisibility, setSupportSecondaryProgress, startActionMode, supportInvalidateOptionsMenu`

    - ### Methods inherited from class android.support.v4.app.Watson

      `onCreatePanelMenu, onMenuItemSelected, onPreparePanel`

    - ### Methods inherited from class android.support.v4.app.FragmentActivity

      `dump, getLastCustomNonConfigurationInstance, getSupportFragmentManager, getSupportLoaderManager, onActivityResult, onAttachFragment, onBackPressed, onCreateView, onKeyDown, onLowMemory, onResumeFragments, onRetainCustomNonConfigurationInstance, onRetainNonConfigurationInstance, onStart, startActivityForResult, startActivityFromFragment`

    - ### Methods inherited from class android.app.Activity

      `closeContextMenu, createPendingResult, dismissDialog, dispatchGenericMotionEvent, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, findViewById, finish, finishActivity, finishActivityFromChild, finishAffinity, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMenuInflater, getParent, getParentActivityIntent, getPreferences, getRequestedOrientation, getSystemService, getTaskId, getTitle, getTitleColor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, isChangingConfigurations, isChild, isDestroyed, isFinishing, isTaskRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onApplyThemeResource, onAttachedToWindow, onAttachFragment, onChildTitleChanged, onContentChanged, onContextItemSelected, onContextMenuClosed, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreatePanelView, onCreateThumbnail, onCreateView, onDetachedFromWindow, onGenericMotionEvent, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onNavigateUp, onNavigateUpFromChild, onOptionsMenuClosed, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onRestart, onSearchRequested, onTouchEvent, onTrackballEvent, onTrimMemory, onUserInteraction, onUserLeaveHint, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, openContextMenu, overridePendingTransition, recreate, registerForContextMenu, removeDialog, requestWindowFeature, runOnUiThread, setDefaultKeyMode, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setIntent, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setTitle, setTitle, setTitleColor, setVisible, setVolumeControlStream, shouldUpRecreateTask, showDialog, showDialog, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityForResult, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderForResult, startIntentSenderForResult, startIntentSenderFromChild, startIntentSenderFromChild, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startSearch, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterForContextMenu`

    - ### Methods inherited from class android.view.ContextThemeWrapper

      `applyOverrideConfiguration, attachBaseContext, getResources, getTheme, setTheme`

    - ### Methods inherited from class android.content.ContextWrapper

      `bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createConfigurationContext, createDisplayContext, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getObbDir, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getSharedPreferences, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startInstrumentation, startService, stopService, unbindService, unregisterReceiver`

    - ### Methods inherited from class android.content.Context

      `getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, registerComponentCallbacks, unregisterComponentCallbacks`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### mTabHost

          private android.widget.TabHost mTabHost

    - #### mViewPager

          private android.support.v4.view.ViewPager mViewPager

    - #### mTabsAdapter

          private TabsAdapter mTabsAdapter

    - #### writer

          private NFCWriter writer

    - #### reader

          private NFCReader reader

    - #### pendingIntent

          private android.app.PendingIntent pendingIntent

    - #### mAdapter

          private android.nfc.NfcAdapter mAdapter

  - ### Constructor Detail

    - #### MainActivity

          public MainActivity()

  - ### Method Detail

    - #### onCreate

          protected void onCreate(android.os.Bundle savedInstanceState)

      This method builds the main user interface using the TabsAdapter class.
      Overrides:
        `onCreate` in class `android.support.v4.app.FragmentActivity`
      See Also:
        `FragmentActivity.onCreate(android.os.Bundle)`

    - #### checkNFC

          private void checkNFC()

      Check if a NFC adapter is available and/or activated. This method checks if a NFC adapter is available on the used Phone and if so if it is enabled. If no adapter is available the app will show a message and than close itself. If an adapter is available but not enabled the app will suggest to open the settings to activate it. If not activated the app will close itself.

    - #### onPause

          public void onPause()

      Overrides:
        `onPause` in class `com.actionbarsherlock.app.SherlockFragmentActivity`

    - #### onResume

          public void onResume()

      Overrides:
        `onResume` in class `android.support.v4.app.FragmentActivity`

    - #### onNewIntent

          protected void onNewIntent(android.content.Intent intent)

      Overrides:
        `onNewIntent` in class `android.support.v4.app.FragmentActivity`

    - #### doProcess

          private void doProcess(android.content.Intent intent)

      This method checks and send the chosen command. This method is called from the onNewIntent method of the activity and initializes the tag, writer and reader attribute. Depending on the tab on which the user clicks on a button the method will use the methods of the respective fragment class. If the user is on the SendText tab the app will ask if the command should be send or not.

    - #### sendData

          protected void sendData(boolean b,
                      android.nfc.Tag tag)
                           throws java.io.IOException,
                                  android.nfc.FormatException

      This method simply processes the command sending only from the SendTextFragment. First either the highspeed on or off command will be send. And after that depending on the given boolean parameter it will send the command or not.
      Parameters:
        `b` - true if the command should be send.
        `tag` - the NFC tag from the intent
      Throws:
        `java.io.IOException`
        `android.nfc.FormatException`