Tizen Cookbook
Total Page:16
File Type:pdf, Size:1020Kb
www.allitebooks.com Tizen Cookbook Over 100 hands-on recipes to develop, deploy, and debug applications using the exciting Tizen platform Leon Anavi BIRMINGHAM - MUMBAI www.allitebooks.com Tizen Cookbook Copyright © 2014 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: October 2014 Production reference: 1081014 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78398-190-8 www.packtpub.com Cover image by Leon Anavi ([email protected]) www.allitebooks.com Credits Author Project Coordinator Leon Anavi Harshal Ved Reviewers Proofreaders Philippe Coval Maria Gould Victor Galindo Ameesha Green David King Paul Hindle Oytun Eren SENGUL Indexers Commissioning Editor Hemangini Bari Usha Iyer Mariammal Chettiyar Monica Ajmera Mehta Acquisition Editor Rekha Nair Rebecca Youé Tejal Soni Content Development Editor Production Coordinator Dayan Hyames Nilesh Mohite Technical Editors Cover Work Shruti Rawool Nilesh Mohite Anand Singh Copy Editors Roshni Banerjee Sarang Chari Janbal Dharmaraj www.allitebooks.com About the Author Leon Anavi is a professional software engineer and an open source enthusiast focused on mobile applications and platforms. He is a regular contributor to Qt for Tizen, Tizen projects, and various other open source projects. He is the founder of the open source project Tizen-sunxi, which ports Tizen to devices with Allwinner SoCs. He has won several awards and earned honorable mentions from competitions organized by Samsung, Intel, Nokia, BlackBerry, and maemo.org. He earned a Bachelor's degree in Computer Systems and Technologies from Technical University of Sofia in 2008; a Master's degree in Information Technologies from Technical University of Sofia in 2010; and a Master of Business Administration degree from New Bulgarian University, Sofia, in 2011. He was a speaker at the following conferences: f Mobile Monday Sofia in January 2011 f Openmobility Conference 2013, Bratislava, in April 2013 f PlovDev 2013, Plovdiv, Bulgaria, in October 2013 f OpenFest 2013, Sofia, Bulgaria, in November 2013 f FOSDEM 2014, Brussels, Belgium, in February 2014 f Tizen Developer Conference 2014, San Francisco, U.S., in June 2014 He was also a co-founder of and speaker at TuxCon 2014, Plovdiv, Bulgaria. www.allitebooks.com About the Reviewers Philippe Coval has been a Free/Libre Open Source Software (FLOSS) enthusiast ever since the late '90s, when he discovered UNIX at university and replaced his Amiga with a GNU/Linux system at home. He has since contributed to various communities such as Debian, Openmoko, Maemo, and Qt, and is currently focused on Tizen. After a decade of working as a software engineer in different contexts (a research lab, Telco, the CE industry, and a start-up), he had the opportunity to join the Tizen project in an open source department of a larger French company known as Eurogiciel. For the past couple of years, he has been maintaining some parts of the Tizen distribution and actively supports community contributions. Feel free to contact him online at https://wiki.tizen.org/wiki/User:Pcoval. I would like to thank my friend Leon for his faithful dedication to sharing his research with the FLOSS hacking scene. Victor Galindo is a software engineer at CBG Konsult in Barcelona. The company develops and sells high-tech translation solutions for customers such as Volvo and General Motors. He works with cutting-edge technologies to deliver the best solutions to customers. Prior to that, he worked in other tech fields such as materials research at Diopma. He also likes to get involved and collaborate with open source projects; you can find him on GitHub. When he is not wired to a computer, he likes to spend time outside in the mountains with his family and cross-country running with his dogs. David King studied Chemistry at the University of Bath, earning his Bachelor's degree in 2005 and his PhD in 2011. Then, he started software development at Openismus GmbH, a small open source consultancy in Berlin, Germany, specializing in mobile and desktop development with Qt and GTK+. He now works for Red Hat and is focused on desktop applications and libraries for GNOME. He maintains EasyTAG and Cheese, among other applications. I would like to thank my wife for looking after our (increasingly large) flock of chickens during the review process. Oytun Eren SENGUL is interested in everything related to mobile, community, operating systems, and kernels. However, he's currently working on mobile UX projects and is the community manager of Smartface Inc., mostly writing developer documents and managing content, public speaking, and conferences. He had started with Maemo and MeeGo, but now he is developing for iOS, Android, Windows Phone, and Tizen. He is a proud member of the Linux Foundation and is a contributor to Intel software projects. He is one of the developers of Automotive Grade Linux. Currently, he is working on SLP and presents his studies at various conferences. He has participated in various Nokia and Turkcell projects as a community manager. I would like to thank my wife, Seval, for her support and patience throughout this project. Now, she knows everything related to mobile operating systems such as Tizen, iOS, and Android even though her background is Turkish literature. www.PacktPub.com Support files, eBooks, discount offers, and more You might want to visit www.PacktPub.com for support files and downloads related to your book. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version atwww.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks. TM http://PacktLib.PacktPub.com Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. Why Subscribe? f Fully searchable across every book published by Packt f Copy and paste, print and bookmark content f On demand and accessible via web browser Free Access for Packt account holders If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access. Table of Contents Preface 1 Part 1 – Getting Started with Tizen Chapter 1: The Tizen SDK 9 Introduction 9 Installing the Tizen SDK 10 Installing the Tizen SDK on Windows 12 Installing the Tizen SDK on Mac OS 13 Installing the Tizen SDK on Ubuntu 14 Managing extension packages 19 Customizing the Tizen IDE 20 Setting the Active Secure profile 22 Tizen Web Simulator 24 Tizen Emulator 25 Getting started with Smart Development Bridge 28 Using Smart Development Bridge 30 Chapter 2: Introduction to the Tizen Ecosystem 33 Introduction 33 The Tizen app life cycle 34 Tizen web app programming 36 Tizen web APIs 39 Localizing Tizen web apps 41 Packaging Tizen web apps 44 Tizen native app programming 45 Packaging Tizen native apps 49 Becoming a Tizen Store seller 51 Publishing apps to Tizen Store 52 Table of Contents Part 2 – Creating Tizen Web Applications Chapter 3: Building a UI 57 Introduction 57 An overview of widgets 57 Creating buttons 60 Creating list views 63 Showing pop ups 66 Using the Tizen Notification API 69 Customizing the look and feel 73 Drawing and writing text on a canvas 76 Creating 3D objects with WebGL 79 Chapter 4: Storing Data 89 Introduction 89 Writing files 90 Reading files 92 Creating a simple text editor 95 Downloading files 100 Using web storage 105 Creating Web SQL Database 109 Executing queries in Web SQL Database 111 Retrieving data from Web SQL Database 112 Using IndexedDB 116 Chapter 5: Creating Multimedia Apps 121 Introduction 121 Playing local audio files 122 Playing local video files 124 Launching video in an external player 129 Taking a photo 132 Generating linear barcodes 135 Scanning linear barcodes 137 Generating QR codes 140 Scanning QR codes 143 Chapter 6: Developing Social Networking Apps 147 Introduction 147 Developing Facebook apps in Tizen 148 Fetching a Facebook news feed 152 Obtaining Facebook friends list 154 Accessing Facebook profile information 156 Reading Facebook messages 158 ii Table of Contents Retrieving Facebook notifications 162 Updating a Facebook status 164 Filtering a Tizen news feed from Twitter 166 Developing a LinkedIn app in Tizen 169 Retrieving