Windows Phone 8 Development Internals

Book description

Build and optimize Windows Phone 8 apps for performance and security

Drill into Windows Phone 8 design and architecture, and learn best practices for building phone apps for consumers and the enterprise. Written by two senior members of the core Windows Phone Developer Platform team, this hands-on book gets you up to speed on the Windows 8 core features and application model, and shows you how to build apps with managed code in C# and native code in C++. You’ll also learn how to incorporate Windows Phone 8 features such as speech, the Wallet, and in-app purchase.

Discover how to:

  • Create UIs with unique layouts, controls, and gesture support

  • Manage databinding with the Model View ViewModel pattern

  • Build apps that target Windows Phone 8 and Windows Phone 7

  • Use built-in sensors, including the accelerometer and camera

  • Consume web services and connect to social media apps

  • Share code across Windows Phone 8 and Windows 8 apps

  • Build and deploy company hub apps for the enterprise

  • Start developing games using Direct3D

  • Test your app and submit it to the Windows Phone Store

  • Table of contents

    1. Windows Phone 8 Development Internals
    2. Dedication
    3. Foreword
    4. Introduction
      1. Who should read this book
        1. Assumptions
      2. Who should not read this book
      3. Organization of this book
      4. Conventions and features in this book
      5. System requirements
      6. Code samples
        1. Installing the code samples
        2. Using the code samples
      7. Acknowledgments
      8. Errata & book support
      9. We want to hear from you
      10. Stay in touch
    5. I. Core Features
      1. 1. Vision and architecture
        1. A different kind of phone
          1. The user interface
            1. Light and simple
            2. Typography
            3. Motion
            4. Content, not chrome
            5. Honesty in design
          2. The role of apps
        2. Windows phone architecture
          1. Platform stack
          2. App types
          3. Background processing
            1. Background OS services
              1. Background transfer service
              2. Alarms
            2. Background audio agents
            3. Scheduled tasks
            4. Continuous background execution for location tracking
          4. Security model
          5. Windows and Windows Phone: together at last
            1. Shared core
            2. Windows Runtime
        3. Building and delivering apps
          1. Developer tools
            1. Windows Phone emulator system requirements
            2. Building for Windows Phone 7.x and 8.x
          2. App delivery
        4. Getting started with “Hello World”
          1. Creating a project
          2. Understanding the project structure
          3. Greeting the world from Windows Phone
          4. Deploying to a Windows Phone device
          5. The Windows Phone Toolkit
        5. Summary
      2. 2. App model and navigation
        1. The app lifecycle
          1. Normal termination
          2. App deactivated—fast app resume
          3. App deactivated—the tombstone case
          4. Setting a resume policy
          5. Obscured and Unobscured
        2. The page model
          1. Page creation order
        3. Navigation and state
          1. App state
          2. Page state
          3. Cancelling navigation
          4. Backstack management
        4. Navigation options
          1. Using NavigateUri
          2. Pages in separate assemblies
          3. Fragment and QueryString
          4. The NavigationMode and IsNavigationInitiator properties
          5. Re-routing navigation and URI mappers
        5. File type and URI associations
          1. Starting an app based on a file or URI
          2. Acting as a file type or URI handler
            1. Manifest registration
            2. Handling activation
            3. Accessing launched files
        6. Summary
      3. 3. UI visuals and touch
        1. Phone UI elements
          1. Standard UI elements
          2. The visual tree
          3. Screen layout
        2. Working with UserControls vs. custom controls
        3. Re-templating controls
        4. Resources
          1. Data resources
          2. XAML resources and resource dictionaries
        5. Implicit styles
        6. Dependency and attached properties
          1. Dependency properties
          2. Attached properties
        7. The app bar and notification area
        8. Transient panels
        9. Routed events
        10. Logical touch gestures
        11. Manipulation events
        12. Mouse events
        13. FrameReported events
        14. Keyboard input
        15. Summary
      4. 4. Data binding and MVVM
        1. Simple data binding and INotifyPropertyChanged
        2. Data-binding collections
          1. Dynamic data-bound collections
          2. Command binding
          3. Template resources
          4. Sorting and grouping bound collections
        3. Type/value converters
        4. Element binding
        5. Data validation
        6. Separating concerns
          1. The Model-View-ViewModel pattern
          2. The Visual Studio databound application project
          3. MVVM in Pivot apps
          4. Row filtering in Pivot apps
          5. Improving the Visual Studio Databound Application template
        7. Summary
      5. 5. Phone and media services
        1. Launchers and Choosers
        2. Search extensibility
          1. App Connect
          2. App Instant Answer
        3. Audio and video APIs
        4. Media playback
          1. The MediaPlayerLauncher
          2. The MediaElement class
          3. The MediaStreamSource and ManagedMediaHelpers classes
          4. The MediaElement controls
        5. Audio input and manipulation
          1. The SoundEffect and SoundEffectInstance classes
          2. Audio input and the microphone
          3. The DynamicSoundEffectInstance class
        6. Music and Videos Hub
        7. The Clipboard API
        8. Summary
      6. 6. Sensors
        1. Orientation
        2. Phone hardware
        3. Sensor APIs
        4. The accelerometer
          1. Reactive extensions
          2. The Level Starter Kit
          3. Shake
        5. Compass
        6. Gyroscope
        7. Motion APIs
        8. Summary
      7. 7. Web connectivity
        1. The WebClient and HttpWebRequest classes
          1. Using the async pack
          2. Using the Task Parallel Library
        2. The WebBrowser control
          1. Local webpages
          2. Integrating with JavaScript
        3. Live SDK
          1. SkyDrive
        4. Facebook
        5. Twitter
        6. The Data Sense feature
        7. Summary
      8. 8. Web services and the cloud
        1. Web services
          1. Localhost and the emulator
          2. Connecting to the web service
          3. SOAP vs. REST
        2. WCF data services
          1. Creating an OData client
          2. Filtered queries
          3. Dynamic query results
          4. Paging the data
          5. Caching the data
          6. JSON-formatted data
        3. Web service security
        4. Windows Azure
          1. Windows Azure web services
          2. Windows Azure Mobile Services for Windows Phone
        5. Summary
      9. 9. Background agents
        1. Background tasks
        2. Alarms and reminders
          1. Alarms
          2. Reminders
        3. The Background Transfer Service
        4. Generic Background Agents
          1. GBA components
          2. Updating tiles
          3. The lock-screen background
          4. Lock-screen notifications
        5. Background audio
          1. Background audio application
          2. Background audio agent
        6. Summary
      10. 10. Local storage and databases
        1. Local storage
          1. Isolated storage APIs
            1. Isolated storage settings
            2. Isolated storage files
          2. Windows Runtime storage
          3. Win32 APIs
        2. LINQ-to-SQL
          1. Defining the database in code
          2. Performing queries
          3. Create/update/delete
          4. Associations
          5. Handling schema changes
          6. Prepopulating a reference database
          7. Maximizing LINQ-to-SQL performance
            1. Minimizing memory usage
            2. Speeding up batch updates
        3. SQLite
          1. Acquiring SQLite for Windows Phone
          2. Using SQLite from managed code
        4. Summary
    6. II. Windows Phone 7 to Windows Phone 8
      1. 11. App publication
        1. Preparing for publication
        2. The publication process
        3. Dev Center reports
        4. Updates
        5. Beta testing
        6. Versions
        7. Selective targeting
          1. Device capabilities
          2. Device memory
        8. Summary
      2. 12. Profiling and diagnostics
        1. Debugging
          1. Targeting different device configurations
          2. Troubleshooting app startup
          3. Using Fiddler with the Windows Phone emulator
        2. Testing
          1. Unit testing
          2. Simulating real-world conditions
          3. Testing tombstoning
          4. The Windows Phone emulator
            1. Emulator keyboard shortcuts
            2. Emulator vs. device
        3. Profiling
          1. Frame rate counters
          2. Redraw regions
          3. DeviceStatus Memory APIs
          4. The Windows Phone Performance Analysis Tool
            1. The app analysis report
            2. Memory analysis report
          5. Profiling native code
        4. Performance best practices
          1. Keep the user engaged
          2. Stay off of the UI thread
          3. Simplify the visual tree
          4. Easy wins with photos
          5. Use LongListSelector instead of ListBox for large collections
          6. Use panorama thoughtfully
        5. Summary
      3. 13. Porting to Windows Phone 8 and multitargeting
        1. Lighting up a Windows Phone 7 App with Windows Phone 8 features
          1. Creating Windows Phone 8 tiles in a Windows Phone 7 App
            1. Registering for the tiles AppExtra
            2. Checking the OS version
            3. Upgrading existing tiles
            4. Adding new tiles
            5. Simulating OS upgrade and App update
        2. Quirks mode and breaking changes
          1. Quirks mode
          2. Breaking changes
          3. Use of MessageBox during app lifecycle events
            1. Anonymous user ID
            2. FM radio
            3. Photo apps picker
            4. LayoutUpdated timing
            5. The WebBrowser control
              1. General rendering and scrolling
              2. User agent string
            6. Text input events
            7. Slider control
            8. XML serialization
            9. The LongListSelector control
            10. Read-only database connections in local storage
        3. Managing platform-specific projects
          1. Create distinct apps for Windows Phone 7.1 and Windows Phone 8
          2. Share a Windows Phone 7.1 library
          3. Link source code files
          4. Create abstract base classes and partial classes
        4. Windows Phone 7.8 SDK
        5. Test coverage for Windows Phone 7.x apps
        6. Summary
      4. 14. Tiles and notifications
        1. Tile sizes and templates
        2. Secondary tiles
          1. Pinning tiles
          2. Cross-targeting Windows Phone 7
        3. Push notifications
        4. Push notification server
        5. Push notification client
        6. Registration web service
        7. Additional server features
          1. Batching intervals
          2. XML payload
          3. Response information
        8. Additional client features
          1. The ErrorOccurred event
          2. User opt-in/out
          3. Implementing a push viewmodel
        9. Push notification security
        10. Summary
      5. 15. Contacts and calendar
        1. Contacts
          1. Understanding the People Hub
          2. Querying device contacts
            1. Single-contact choosers
            2. Querying contacts programmatically
          3. Adding contact information
          4. Creating a custom contacts store
        2. Calendar
          1. Querying the calendar
          2. Creating a new appointment
        3. Summary
      6. 16. Camera and photos
        1. Acquiring a single photo
        2. Working with the media library
          1. Reading photos
          2. Adding new images
        3. Capturing photos
          1. The PhotoCamera class
          2. The PhotoCaptureDevice class (Windows Phone 8 only)
            1. Preparing the device and capture sequence
            2. Manipulating the preview buffer
            3. Capturing a photo
            4. Capturing video
        4. Extending the Photos Hub
          1. Apps pivot
          2. The photo apps picker and photo edit picker
            1. The photo apps picker (Windows Phone 7.1 only)
            2. The photo edit picker (Windows Phone 8 only)
        5. Lenses
          1. Launching from the camera
          2. Rich media editing
        6. Sharing photos
          1. Share picker
          2. Auto-upload
        7. Summary
      7. 17. Networking and proximity
        1. Sockets
          1. The Windows Runtime sockets API
          2. .NET sockets
          3. The WinSock API
        2. Finding your app on nearby devices
          1. Finding peers through Bluetooth
          2. Finding peers through tap-to-connect
          3. Reconnecting without retapping
          4. Tap-to-connect with a Windows 8 app
        3. Connecting to other Bluetooth devices
        4. NFC
          1. Reading and writing NFC tags
          2. Writing URIs to tags
          3. Writing NDEF messages directly
          4. Writing a LaunchApp tag
          5. Sending a URI across devices
        5. Summary
      8. 18. Location and maps
        1. Architecture
        2. Determining the current location (Windows Phone 7)
        3. Bing maps (Windows Phone 7)
          1. The Bing Map control
          2. Bing maps web services
          3. Bing Maps Launchers
        4. Getting location (Windows Phone 8)
        5. Maps API (Windows Phone 8)
          1. The Map control
          2. Route and directions
          3. Maps Launchers
        6. Continuous background execution (Windows Phone 8)
        7. Testing location in the simulator
        8. Location best practices
        9. Summary
    7. III. New Windows Phone 8 Features
      1. 19. Speech
        1. Voice commands
          1. The GSE
          2. Building a simple voice commands App
            1. Registering voice commands
            2. Initializing the VCD file
            3. Handling invocation for simple voice commands
          3. Adding flexibility by using labels
          4. Updating PhraseLists at run time
        2. Speech recognition in apps
          1. Simple recognition with built-in UX
          2. Customizing the recognizer UI
          3. Adding custom grammars
            1. Adding predefined grammars
            2. Adding simple lists
            3. Adding grammars by using speech recognition grammar specification
        3. Text-to-Speech
          1. Simple TTS with SpeakTextAsync
          2. Taking control with speech synthesis markup language
            1. Crafting the speech output
            2. Keeping speech and screen in sync
        4. Putting it together to talk to your apps
        5. Summary
      2. 20. The Wallet
        1. Understanding the Wallet
          1. The Wallet and Near Field Communication
          2. The Wallet Hub
        2. The Wallet object model
          1. Managing deals
          2. Transaction items
            1. Adding and removing the account in the app
            2. Handling the addition and removal of accounts in the Wallet
          3. Payment instruments
        3. Wallet agents
        4. Summary
      3. 21. Monetizing your app
        1. Advertising
          1. Integrating the Ad Control
          2. Ad Control design guidelines
            1. Positioning
            2. Integration with panorama and pivot controls
            3. Creating a common Ad Unit across all pages
          3. Registering with Microsoft pubCenter
        2. Trial mode
        3. In-app purchase
          1. Division of responsibilities
          2. Types of IAP content
          3. Configuring the mock IAP library
          4. Purchasing durable content
          5. Purchasing consumable content
          6. Configuring IAP inventory
        4. Summary
      4. 22. Enterprise apps
        1. Windows Phone for business
        2. Managed vs. unmanaged phones
          1. MDM and managed phones
          2. Managed enrollment
        3. Unmanaged phones
          1. Unmanaged enrollment
        4. Company Apps
        5. Building a company hub app
        6. Summary
    8. IV. Native Development and Windows Phone 8 convergence
      1. 23. Native development
        1. Native code overview
          1. When to use native code
            1. Portability
            2. Reusability
            3. Performance
        2. An introduction to modern C++
          1. Smart pointers
            1. Unique pointers
            2. Shared Pointers
            3. Type Inference
          2. Foreach loops
          3. Lambdas
          4. Scoped, strongly typed enums
          5. What about properties and events?
        3. Managed-native interop
          1. Creating the Windows Runtime component
          2. Consuming the Windows Runtime component from C#
          3. Debugging mixed-mode projects
        4. Writing asynchronous code in C++
          1. Moving synchronous code to the background
          2. Providing progress updates
          3. Cancelling asynchronous operations
        5. Using Windows Runtime classes in C++
        6. Win32 API
        7. Component Object Model (COM)
          1. Supported platform COM libraries
          2. Using custom COM libraries
        8. Summary
      2. 24. Windows 8 convergence
        1. Windows 8 and Windows Phone 8 compared
          1. Developer tools and supported languages
          2. Application models
          3. Frameworks
            1. Windows Phone framework namespaces explained
            2. Windows Runtime API comparison
            3. Non-converged frameworks
            4. Direct3D
          4. Background processing
            1. Generic background processing
            2. Background audio
            3. Voice over IP
            4. Background location tracking
          5. Authoring Windows Runtime components on Windows Phone
        2. Sharing code between Windows and Windows Phone
          1. Deciding when and how to share code
          2. Code sharing and Model-View-ViewModel
          3. Sharing .NET code by using the PCL
            1. Creating the project
            2. Handling platform differences
          4. Linked files and conditional compilation
          5. Sharing managed code with partial classes
          6. Sharing native code
          7. Sharing XAML-based UI with user controls
            1. Dealing with built-in styles
            2. Taking the UserControl cross-platform
            3. Reusing phone UI in Windows snapped view
        3. Summary
      3. 25. Games and Direct3D
        1. Direct3D primer
        2. Direct3D differences on Windows Phone
        3. Visual Studio project types
        4. Direct3D and XAML projects
        5. Structure of the basic Direct3D app
          1. The CoreApplication and CoreWindow classes
          2. Starter code classes
          3. Initializing Direct3D
          4. A brief word about the Component Object Model
          5. DirectX hardware feature levels
          6. Update and render
        6. Minimal Direct3D app
        7. Touch input
        8. Direct2D and DirectXTK
        9. Summary
    9. A. About the Authors
    10. Index
    11. About the Authors
    12. Copyright

    Product information

    • Title: Windows Phone 8 Development Internals
    • Author(s): Andrew Whitechapel and Sean McKenna
    • Release date: June 2013
    • Publisher(s): Microsoft Press
    • ISBN: 9780735676220