Sunteți pe pagina 1din 13

Ben Morris et al

Introduction to bada
A Developer’s Guide

ht
y rig
op
erC
nd
U
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Introduction to bada

h t
ig
This electronic book is the draft manuscript for ‘Introduction to bada: A Developer’s Guide’. In
yr
this sneak preview you can access all the content to be included in the printed version of this
op
book, apart from approximately 60 recipes which are still to come. The printed book will be
available for sale worldwide in September 2010 (ISBN 978-0-470-97401-8).
C
er
nd
U

i
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Introduction to bada
A Developer’s Guide

t
Ben Morris

h
ig
and

Manfred Bortenschlager, Jon Lansdell, Cheng Luo, Michelle Somerville


yr
op
With review and input by:
C

Hyeyoung Jung, HoKyung Kim, Hyun Gyoo Yook


er

. . . and many others on the Samsung bada Team


nd
U

A John Wiley and Sons, Ltd, Publication

ii
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

This edition first published 2010


© 2010 Samsung Electronics, Co., Ltd.

Registered office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex,
PO19 8SQ, United Kingdom

Editorial office
John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex,
PO19 8SQ, United Kingdom

For details of our global editorial offices, for customer services and for information about how to apply for
permission to reuse the copyright material in this book please see our website at www.wiley.com/wiley-
blackwell.

The right of the author to be identified as the author of this work has been asserted in accordance with
the Copyright, Designs and Patents Act 1988.

h t
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form or by any means, electronic, mechanical, photocopying, recording or otherwise,

ig
except as permitted by the UK Copyright, Designs and Patents Act 1988, without the prior permission of
the publisher.

yr
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
op
Designations used by companies to distinguish their products are often claimed as trademarks. All brand
names and product names used in this book are trade names, service marks, trademarks or registered
C

trademarks of their respective owners. The publisher is not associated with any product or vendor
mentioned in this book. This publication is designed to provide accurate and authoritative information in
regard to the subject matter covered. It is sold on the understanding that the publisher is not engaged in
er

rendering professional services. If professional advice or other expert assistance is required, the services
of a competent professional should be sought.
nd

Samsung logo/images are reproduced with permission from Samsung Electronics (UK) Limited, a
company incorporated in England and Wales under registered number 03086621 and whose registered
office is at Samsung House, 1000 Hillswood Drive, Chertsey, Surrey KT16 0PS, UK. If you wish to
reproduce the Samsung trademark you must contact Samsung Electronics for permission.
U

978-0-470-97605-0 [e-book]

978-0-470-97401-8 [print ISBN]

iii
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Contents
About this ePublication ............................................................................................................................... vii

Preface ....................................................................................................................................................... viii

Introduction ................................................................................................................................................... 1

Overview of the book................................................................................................................................ 1

h t
Part 1: About bada ........................................................................................................................................ 3

ig
Chapter 1: The mobile difference ................................................................................................................. 4

yr
1.1 The mobile context ............................................................................................................................. 4
op
1.2 Characteristics of mobile software ...................................................................................................... 6
C

1.3 Mobile app development best-practices ............................................................................................ 10

Chapter 2: bada basics ................................................................................................................................ 15


er

2.1 Your first bada application................................................................................................................ 16


nd

2.2 The application UI ............................................................................................................................ 26

2.3 UI Builder ......................................................................................................................................... 32


U

2.4 Hooking up your Forms to your code ............................................................................................... 42

2.5 The App Icon and other properties ................................................................................................... 49

2.6 Becoming multilingual in 3 easy steps ............................................................................................. 50

2.7 From idea to published app ............................................................................................................... 54

Chapter 3: Beyond the basics ...................................................................................................................... 70

3.1 Expanding the application skeleton .................................................................................................. 70


iv
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

3.2 Using the UI Framework .................................................................................................................. 78

3.3 Using graphics .................................................................................................................................. 88

3.4 The BuddyFix UI revisited ............................................................................................................. 105

Chapter 4: bada fundamentals ................................................................................................................... 116

4.1 Architecture overview ..................................................................................................................... 116

4.2 bada coding idioms ......................................................................................................................... 117

4.3 bada basic functionality .................................................................................................................. 138

4.4 Security and the privilege model in bada ........................................................................................ 147

h t
Chapter 5: Exploring bada server.............................................................................................................. 151

ig
5.1 What are the services? .................................................................................................................... 151

yr
5.2 How it works ................................................................................................................................... 155
op
5.3 Services in detail ............................................................................................................................. 158

Chapter 6: bada Namespaces .................................................................................................................... 189


C

6.1 using directives and declarations ................................................................................................. 190


er

6.2 How this chapter is organized ......................................................................................................... 192


nd

6.3 Namespaces in detail....................................................................................................................... 195

Part 2: Recipes .......................................................................................................................................... 258


U

Introduction ........................................................................................................................................... 260

2.1 Adding a Form ................................................................................................................................ 262

2.2 Adding a button to a Form .............................................................................................................. 267

2.3 Adding softkeys to a Form .............................................................................................................. 274

2.4 Adding an option menu to a Form .................................................................................................. 278

2.5 Display MessageBox to confirm an action ..................................................................................... 284

v
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

2.6 Using a keypad control ................................................................................................................... 288

2.7 Get touch events.............................................................................................................................. 298

2.8 Using base applications................................................................................................................... 306

2.9 Get magnetic field from Compass Sensor....................................................................................... 315

2.10 Get geographic data from provider and show map ....................................................................... 321

Appendix A: A UML primer .................................................................................................................... 327

Appendix B: A software engineering process model for mobile app development.................................. 329

h t
ig
yr
op
C
er
nd
U

vi
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

About this ePublication


At the end of last year, Samsung announced the launch of bada (the Korean word for ‘Ocean’), our very
own native platform for application development.

From the outset we planned to produce a beginners’ guide to bada, and to get you started as quick as we
could, we decided to publish this book in two phases: first as an ePublication, and later as a full print
version. Right now you are reading the ePublication, which is a shorter version of the print version which
will be available later this year. The team would be delighted to hear back from you with any feedback
and requests you may have - we’ll see if we can include them in a future book. But now, a bit more about
bada…

h t
The bada platform is a significant engineering feat. Its open APIs provide a platform for innovation

ig
comparable (and in many areas superior to) other platforms. However, open APIs alone do not make an

yr
ecosystem flourish. Like other successful platforms, bada is only part of a much bigger picture of
company-wide innovation. Many other groups in Samsung have been involved in creating the end-to-end
op
model that will help this platform deliver its technological promise.
C

This book is your introduction to the bada platform. It will give you the information you need to get
developing great applications on our powerful and well-abstracted SDK, making the most of the bada
er

server, and getting your app into the hands of the user. The book and further resources can be accessed on
our website http://developer.bada.com.
nd

Good luck, and we look forward to creating the new wave of the smartphone story with you.
U

The bada Team

vii
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Preface
Samsung announced its bada platform for mobile phones towards the end of 2009. New mobile platforms
don't come along every day, but 2009 was a busy year in mobile, and most attention remained with the
existing platforms.

Some avid Samsung watchers paid a little more attention and when the first bada phone, the Samsung
Wave, previewed at Mobile World Congress in February 2010, you could begin to detect a little

t
excitement.

h
ig
The bada SDK became publicly available for the first time in May 2010, and at the same time Samsung

yr
announced its Global Developer Challenge for bada apps, running until December 2010 with a prize pot
of more than $2.7 million USD, and a Grand Prize of $300,000. That's impressive!
op
Even so, you could be forgiven for thinking that the mobile industry still does not really get bada. After
C

all, who needs another smartphone OS?

This book, we hope, will help put you in the company of those who do get bada. The rolling program of
er

Developer Days through the spring and early summer of 2010 has seen three-thousand and more
nd

developers pick up tools, pick up phones, and get stuck in – from Paris to Peking to St Petersburg, Dublin
to Seoul, Budapest to London, Jo'burg to Istanbul, not forgetting Munich, Madrid and Milan. They get it.
U

Less publicly, Samsung has been working with the kind of companies you've heard of – and probably a
few you haven't – to put their games, services, and cool apps onto bada phones 1 and into SamsungApps,
the brand new Samsung mobile app store. They get it too.

1
If you enjoy name-checking, check out this list: e-Book Pearson Longman, New York Times Entertainment
Mauro, Uangel, Allm Game Capcom, EA Mobile, Gameloft, Digital Chocolate, Namco Bandai, Handmark
Health/Life Mauro, Uangel Info CNN, BBC, Weather channel, ESPN, eBay Media Shazam, Melodis, MTV, Warner
viii
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Wave is now in the shops, pitched squarely at the middle price-band – free on mid-priced contracts in UK
and European markets, sub-£350 SIM-free in the UK – that’s roughly $500 USD. After Wave, the
promise is that bada devices will push down below the $200 USD price point.

The real test now for bada is whether the market gets it.

We’re betting it will. And we hope this book will inspire you to download the SDK, fire up your favourite
editor, and start following along.

Note:
This ePub refers to and is correct for the 1.0.0b3 SDK/IDE version.

h t
ig
The Authors

yr
op
C
er
nd
U

Music Productivity SPB, Diotek, Evernote, Estsoft Reference Lonely Planet, deCarte, Paragon SNS Twitter,
Facebook, Floo, mySpace, Bebo Utility Prompt, Inka, Scanbuy.

ix
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

h t
ig
yr
op
C
er
nd
U

0
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Introduction
This book is for developers. It will get you up and running with your first bada app, quickly. Looking
beyond your first app, we hope this book will find a permanent place on your desk as a bada companion,
with its overviews of the platform, the bada architecture, bada namespaces, APIs, and services – and
above all with its recipes. These have been written by Samsung’s bada development team to give you
more than sixty best-practice examples of common bada APIs in use. You can learn from this code, and
you can reuse this code.

h t
As for the goal of this book, we hope it’s clear – to introduce you to bada, and to make it as easy as

ig
possible to develop cool apps for bada phones.

Overview of the book


yr
op
C

Developing for mobile is never trivial, whatever the platform. Chapter 1 runs through the issues that can
bite you in mobile development. If you are a seasoned mobile developer, you may know the issues
er

already. However, the boom in mobile app development has brought thousands of new developers into
what used to be a niche market. If you are not one of those grizzled types who cut their baby teeth in
nd

embedded, eating ARM assembler for breakfast way back at the dawn of mobile, then this could be for
you. Understanding the mobile difference, and becoming comfortable with it, is the essential starting
U

point for doing mobile development. And if it helps, Chapter 1 also summarises some agile best-practice.
Rules are good for breaking, as well as following, but in either case it's good to know what they are.

Chapter 2 and Chapter 3 show you just how easy it is to get started with bada, introducing the Eclipse-
based IDE and its Application Wizard to work up an example from bare-bones to first demo UI. Other
topics covered include bada’s security/protection model, and the bada developer portal, which provides
the interface to app publishing through the SamsungApps mobile store.

1
Introduction to bada: A Developer's Guide - (draft preview, July 2010)

Chapter 4 moves on to explore the bada platform architecture, and to introduce some important bada
concepts – including bada’s C++ namespaces, class library, and programming idioms.

Chapter 5 introduces bada services, one of bada’s exciting innovations, that integrate APIs for
commerce, social networking, and other service-centric features, with the platform APIs. This makes it
easy to integrate services into your apps to stretch the boundaries of what users can do on mobile.

Note: at the time of writing, some of these services are still restricted to partner developers, so keep an
eye on breaking news on developer.bada.com as the developer story continues to unfold.

To conclude Part 1 of the book, Chapter 6 provides an overview of each of the bada namespaces,
highlighting the most important classes.

h t
Part 2 of the book presents a bunch of recipes, organised into groups that show off the main bada features

ig
and provide you with ready-made code solutions to integrate into your own projects. The e-publication of

yr
the book holds only 10 recipes as a taster for the printed book.
op
C
er
nd
U

S-ar putea să vă placă și