50 Android Hacks

50 Android Hacks

Description

The best programming techniques are often the shortest and simplestthe hacks. In this compact and infinitely useful book, Android expert Carlos Sessa delivers 50 hacks that will save you time, stretch your skills, and maybe even make you smile.
Hacks. Clever programming techniques to solve thorny little problems. Ten lines of code that save you two days of work. The little gems you learn from the old guy in the next cube or from the geniuses on Stack Overflow. Thats just what youll find in this compact and useful book.

Table of contents

50 Android Hacks......Page 1
brief contents......Page 8
contents......Page 10
foreword......Page 18
preface......Page 20
acknowledgments......Page 22
about this book......Page 24
Roadmap......Page 25
Author Online......Page 26
About the author......Page 27
about the cover illustration......Page 28
Hack 1 Centering views using weights......Page 30
1.1 Combining weightSum and layout_weight......Page 31
Hack 2 Using lazy loading and avoiding replication......Page 32
2.1 Avoid replication using the tag......Page 33
2.2 Lazy loading views with the ViewStub class......Page 34
2.4 External links......Page 36
Hack 3 Creating a custom ViewGroup......Page 37
3.2 Creating the CascadeLayout......Page 38
3.3 Adding custom attributes to the children......Page 41
3.4 The bottom line......Page 42
Hack 4 Preferences hacks......Page 43
4.2 External links......Page 46
Hack 5 Snappy transitions with TextSwitcher and ImageSwitcher......Page 48
Hack 6 Adding eye candy to your ViewGroups children......Page 50
Hack 7 Doing animations over the Canvas......Page 52
Hack 8 Slideshow using the Ken Burns effect......Page 54
8.1 The bottom line......Page 56
8.2 External links......Page 57
Hack 9 Avoiding date validations with an EditText for dates......Page 58
Hack 10 Formatting a TextViews text......Page 59
10.2 External links......Page 60
Hack 11 Adding text glowing effects......Page 61
Hack 12 Rounded borders for backgrounds......Page 62
Hack 13 Getting the views width and height in the onCreate() method......Page 63
Hack 14 VideoViews and orientation changes......Page 65
14.1 The bottom line......Page 67
Hack 15 Removing the background to improve your Activity startup time......Page 68
15.1 The bottom line......Page 69
Hack 16 Toasts position hack......Page 70
Hack 17 Creating a wizard form using a Gallery......Page 71
17.2 External links......Page 75
Hack 18 Removing log statements before releasing......Page 76
18.2 External links......Page 77
Hack 19 Using the Hierarchy Viewer tool to remove unnecessary views......Page 78
19.2 External links......Page 81
Hack 20 The Model-View-Presenter pattern......Page 82
20.1 The bottom line......Page 84
Hack 21 BroadcastReceiver following Activitys lifecycle......Page 85
21.1 The bottom line......Page 86
22.1 Back-end logic and model......Page 87
22.3 Android application......Page 88
23.1.1 Using the AsyncTask class......Page 89
23.1.2 Using a Service......Page 90
23.2.1 Whats a SyncAdapter?......Page 91
23.2.2 Hitting a database instead of the server......Page 92
23.2.3 Populating the database......Page 95
23.2.4 Adding login functionality......Page 96
23.2.5 Adding the SyncAdapter......Page 102
23.4 External links......Page 104
Hack 24 Handling empty lists......Page 106
Hack 25 Creating fast adapters with a ViewHolder......Page 107
25.1 The bottom line......Page 109
Hack 26 Adding section headers to a ListView......Page 110
26.1 Creating list layouts......Page 111
26.2 Providing visible section headers......Page 112
26.5 External links......Page 113
Hack 27 Communicating with an Adapter using an Activity and a delegate......Page 114
Hack 28 Taking advantage of ListViews header......Page 116
Hack 29 Handling orientation changes inside a ViewPager......Page 118
29.1 The bottom line......Page 119
Hack 30 ListViews choiceMode......Page 120
30.1 The bottom line......Page 123
30.2 External links......Page 124
Hack 31 Aspect-oriented programming in Android......Page 126
31.2 External links......Page 129
32.2 Using Cocos2d-x......Page 130
32.3 The bottom line......Page 133
32.4 External links......Page 134
Hack 33 Running Objective-C in Android......Page 136
33.2 Creating the modules......Page 137
33.2.2 The textformatter module......Page 138
33.2.3 The main module......Page 139
33.3 Setting up the Java part......Page 141
Hack 34 Using Scala inside Android......Page 142
34.2 External links......Page 145
Hack 35 Firing up multiple intents......Page 146
35.4 The bottom line......Page 147
Hack 36 Getting user information when receiving feedback......Page 148
37.1 Adding the MP3 using content values......Page 150
Hack 38 Adding a refresh action to the action bar......Page 151
38.2 External links......Page 154
Hack 39 Getting dependencies from the market......Page 155
39.1 The bottom line......Page 156
40.1 Starting point: Android sample application......Page 157
40.2 Introducing executors......Page 158
40.3 UI threadleaving and returning seamlessly......Page 159
40.6 External links......Page 160
Hack 41 Building databases with ORMLite......Page 162
41.1 A simple data model......Page 163
41.2 Getting started......Page 164
41.3 Rock-solid database schema......Page 165
41.4 SQLiteOpenHelperyour gateway to the database......Page 167
41.5 Singleton pattern for database access......Page 168
41.6 CRUD operations made easy......Page 169
41.7 Query builders......Page 170
41.8 Data types and tricky foreign types......Page 172
41.9 Raw SQL queries......Page 174
41.10 Transactions......Page 175
41.12 External links......Page 176
42.1 Java code......Page 177
42.2 Native code......Page 178
42.4 External links......Page 180
43.1 No batch......Page 181
43.2 Using batch operations......Page 182
43.3 Applying batch using SQLiteContentProvider......Page 183
43.5 External links......Page 185
Hack 44 Handling lights-out mode......Page 186
44.2 Android 3.x......Page 187
Hack 45 Using new APIs in older devices......Page 189
45.1 Using apply() instead of commit()......Page 190
45.2 Storing the app on the SD card......Page 192
Hack 46 Backward-compatible notifications......Page 193
Hack 47 Creating tabs with fragments......Page 197
47.2 Placing the tabs in an Activity......Page 198
47.4 External links......Page 199
Hack 48 Handling dependencies with Apache Maven......Page 200
48.2 External links......Page 203
Hack 49 Installing dependencies in a rooted device......Page 204
49.2 Creating the permissions XML......Page 205
49.5 External links......Page 206
Hack 50 Using Jenkins to deal with device diversity......Page 207
50.1 Creating a Jenkins job......Page 208
50.2 Running the job......Page 210
50.4 External links......Page 211
B......Page 212
E......Page 213
L......Page 214
O......Page 215
S......Page 216
Z......Page 217

Details

  • Author: Carlos Sessa
  • Edition: Pap/Psc
  • Publication Date: 2013
  • Publisher: Manning Publications
  • ISBN-10: 1617290564
  • ISBN-13: 9781617290565
  • Pages: 218
  • Format: pdf
  • Size: 10.0M
Download Now