Android Notes For Professionals Goalkickercom download
Android Notes For Professionals Goalkickercom download
download
https://ebookbell.com/product/android-notes-for-professionals-
goalkickercom-22033350
https://ebookbell.com/product/android-notes-for-
professionals-1000-pages-of-professional-hints-and-tricks-
goalkickercom-11074470
https://ebookbell.com/product/android-notes-for-professional-learn-
coding-easily-s-k-andrew-andrew-35444188
https://ebookbell.com/product/android-programming-tutorials-
version-32-mark-murphy-46489074
https://ebookbell.com/product/android-smartphones-for-dummies-1st-jf-
dimarzio-46710544
Android Studio Electric Eel Essentials Kotlin Edition Neil Smyth
https://ebookbell.com/product/android-studio-electric-eel-essentials-
kotlin-edition-neil-smyth-47610456
https://ebookbell.com/product/android-for-dummies-dan-gookin-48506312
https://ebookbell.com/product/android-studio-electric-eel-essentials-
java-edition-developing-android-apps-using-android-studio-202211-and-
java-1st-edition-neil-smyth-49039778
https://ebookbell.com/product/android-accessibility-by-tutorials-make-
your-apps-accessible-for-all-audiences-2nd-edition-raywenderlich-
tutorial-team-49540392
https://ebookbell.com/product/android-concurrency-g-blake-
meike-49929122
Android
Android
Notes for Professionals
™
1000+ pages
of professional hints and tricks
Disclaimer
GoalKicker.com This is an unocial free book created for educational purposes and is
not aliated with ocial Android™ group(s) or company(s).
Free Programming Books All trademarks and registered trademarks are
the property of their respective owners
Contents
About ................................................................................................................................................................................... 1
Chapter 1: Getting started with Android ........................................................................................................... 2
Section 1.1: Creating a New Project .............................................................................................................................. 2
Section 1.2: Setting up Android Studio ....................................................................................................................... 13
Section 1.3: Android programming without an IDE .................................................................................................. 14
Section 1.4: Application Fundamentals ...................................................................................................................... 18
Section 1.5: Setting up an AVD (Android Virtual Device) ......................................................................................... 19
Chapter 2: Layouts ..................................................................................................................................................... 23
Section 2.1: LayoutParams ......................................................................................................................................... 23
Section 2.2: Gravity and layout gravity .................................................................................................................... 26
Section 2.3: CoordinatorLayout Scrolling Behavior ................................................................................................. 28
Section 2.4: Percent Layouts ...................................................................................................................................... 30
Section 2.5: View Weight ............................................................................................................................................ 31
Section 2.6: Creating LinearLayout programmatically ........................................................................................... 32
Section 2.7: LinearLayout ........................................................................................................................................... 33
Section 2.8: RelativeLayout ........................................................................................................................................ 34
Section 2.9: FrameLayout .......................................................................................................................................... 36
Section 2.10: GridLayout ............................................................................................................................................. 37
Section 2.11: CoordinatorLayout ................................................................................................................................. 39
Chapter 3: Gradle for Android ............................................................................................................................. 41
Section 3.1: A basic build.gradle file ........................................................................................................................... 41
Section 3.2: Define and use Build Configuration Fields ........................................................................................... 43
Section 3.3: Centralizing dependencies via "dependencies.gradle" file ................................................................. 46
Section 3.4: Sign APK without exposing keystore password .................................................................................. 47
Section 3.5: Adding product flavor-specific dependencies ..................................................................................... 49
Section 3.6: Specifying dierent application IDs for build types and product flavors ......................................... 49
Section 3.7: Versioning your builds via "version.properties" file ............................................................................. 50
Section 3.8: Defining product flavors ........................................................................................................................ 51
Section 3.9: Changing output apk name and add version name: .......................................................................... 51
Section 3.10: Adding product flavor-specific resources .......................................................................................... 52
Section 3.11: Why are there two build.gradle files in an Android Studio project? ................................................. 52
Section 3.12: Directory structure for flavor-specific resources ............................................................................... 53
Section 3.13: Enable Proguard using gradle ............................................................................................................. 53
Section 3.14: Ignoring build variant ............................................................................................................................ 54
Section 3.15: Enable experimental NDK plugin support for Gradle and AndroidStudio ....................................... 54
Section 3.16: Display signing information ................................................................................................................. 56
Section 3.17: Seeing dependency tree ....................................................................................................................... 57
Section 3.18: Disable image compression for a smaller APK file size .................................................................... 58
Section 3.19: Delete "unaligned" apk automatically ................................................................................................ 58
Section 3.20: Executing a shell script from gradle ................................................................................................... 58
Section 3.21: Show all gradle project tasks ............................................................................................................... 59
Section 3.22: Debugging your Gradle errors ............................................................................................................ 60
Section 3.23: Use gradle.properties for central versionnumber/buildconfigurations ......................................... 61
Section 3.24: Defining build types .............................................................................................................................. 62
Chapter 4: RecyclerView onClickListeners .................................................................................................... 63
Section 4.1: Kotlin and RxJava example ................................................................................................................... 63
Section 4.2: RecyclerView Click listener .................................................................................................................... 64
Section 4.3: Another way to implement Item Click Listener ................................................................................... 65
Section 4.4: New Example .......................................................................................................................................... 67
Section 4.5: Easy OnLongClick and OnClick Example ............................................................................................. 68
Section 4.6: Item Click Listeners ................................................................................................................................. 71
Chapter 5: NavigationView .................................................................................................................................... 73
Section 5.1: How to add the NavigationView ............................................................................................................ 73
Section 5.2: Add underline in menu elements .......................................................................................................... 77
Section 5.3: Add seperators to menu ........................................................................................................................ 78
Section 5.4: Add menu Divider using default DividerItemDecoration ................................................................... 79
Chapter 6: Intent ......................................................................................................................................................... 81
Section 6.1: Getting a result from another Activity ................................................................................................... 81
Section 6.2: Passing data between activities ............................................................................................................ 83
Section 6.3: Open a URL in a browser ....................................................................................................................... 84
Section 6.4: Starter Pattern ........................................................................................................................................ 85
Section 6.5: Clearing an activity stack ...................................................................................................................... 86
Section 6.6: Start an activity ....................................................................................................................................... 86
Section 6.7: Sending emails ........................................................................................................................................ 87
Section 6.8: CustomTabsIntent for Chrome Custom Tabs ..................................................................................... 87
Section 6.9: Intent URI ................................................................................................................................................. 88
Section 6.10: Start the dialer ....................................................................................................................................... 89
Section 6.11: Broadcasting Messages to Other Components .................................................................................. 89
Section 6.12: Passing custom object between activities .......................................................................................... 90
Section 6.13: Open Google map with specified latitude, longitude ......................................................................... 92
Section 6.14: Passing dierent data through Intent in Activity ............................................................................... 92
Section 6.15: Share intent ............................................................................................................................................ 94
Section 6.16: Showing a File Chooser and Reading the Result ............................................................................... 94
Section 6.17: Sharing Multiple Files through Intent ................................................................................................... 96
Section 6.18: Start Unbound Service using an Intent ............................................................................................... 96
Section 6.19: Getting a result from Activity to Fragment ........................................................................................ 97
Chapter 7: JSON in Android with org.json ..................................................................................................... 99
Section 7.1: Creating a simple JSON object .............................................................................................................. 99
Section 7.2: Create a JSON String with null value ................................................................................................... 99
Section 7.3: Add JSONArray to JSONObject ............................................................................................................ 99
Section 7.4: Parse simple JSON object ................................................................................................................... 100
Section 7.5: Check for the existence of fields on JSON ......................................................................................... 101
Section 7.6: Create nested JSON object ................................................................................................................. 101
Section 7.7: Updating the elements in the JSON ................................................................................................... 102
Section 7.8: Using JsonReader to read JSON from a stream ............................................................................. 102
Section 7.9: Working with null-string when parsing json ...................................................................................... 104
Section 7.10: Handling dynamic key for JSON response ...................................................................................... 105
Chapter 8: Android Studio ................................................................................................................................... 107
Section 8.1: Setup Android Studio ............................................................................................................................ 107
Section 8.2: View And Add Shortcuts in Android Studio ........................................................................................ 107
Section 8.3: Android Studio useful shortcuts .......................................................................................................... 108
Section 8.4: Android Studio Improve performance tip .......................................................................................... 109
Section 8.5: Gradle build project takes forever ...................................................................................................... 110
Section 8.6: Enable/Disable blank line copy .......................................................................................................... 110
Section 8.7: Custom colors of logcat message based on message importance ............................................... 111
Section 8.8: Filter logs from UI ................................................................................................................................. 112
Section 8.9: Create filters configuration ................................................................................................................. 113
Section 8.10: Create assets folder ........................................................................................................................... 114
Chapter 9: Resources ............................................................................................................................................. 116
Section 9.1: Define colors .......................................................................................................................................... 116
Section 9.2: Color Transparency(Alpha) Level ...................................................................................................... 117
Section 9.3: Define String Plurals ............................................................................................................................. 117
Section 9.4: Define strings ........................................................................................................................................ 118
Section 9.5: Define dimensions ................................................................................................................................ 119
Section 9.6: String formatting in strings.xml ........................................................................................................... 119
Section 9.7: Define integer array ............................................................................................................................. 120
Section 9.8: Define a color state list ........................................................................................................................ 120
Section 9.9: 9 Patches ............................................................................................................................................... 121
Section 9.10: Getting resources without "deprecated" warnings ......................................................................... 124
Section 9.11: Working with strings.xml file ............................................................................................................... 124
Section 9.12: Define string array .............................................................................................................................. 125
Section 9.13: Define integers .................................................................................................................................... 126
Section 9.14: Define a menu resource and use it inside Activity/Fragment ....................................................... 126
Chapter 10: Data Binding Library ..................................................................................................................... 128
Section 10.1: Basic text field binding ........................................................................................................................ 128
Section 10.2: Built-in two-way Data Binding ........................................................................................................... 129
Section 10.3: Custom event using lambda expression .......................................................................................... 130
Section 10.4: Default value in Data Binding ............................................................................................................ 132
Section 10.5: Databinding in Dialog ......................................................................................................................... 132
Section 10.6: Binding with an accessor method ..................................................................................................... 132
Section 10.7: Pass widget as reference in BindingAdapter ................................................................................... 133
Section 10.8: Click listener with Binding ................................................................................................................... 134
Section 10.9: Data binding in RecyclerView Adapter ............................................................................................. 135
Section 10.10: Databinding in Fragment ................................................................................................................. 136
Section 10.11: DataBinding with custom variables(int,boolean) ............................................................................ 137
Section 10.12: Referencing classes ........................................................................................................................... 137
Chapter 11: Exceptions ............................................................................................................................................ 139
Section 11.1: ActivityNotFoundException .................................................................................................................. 139
Section 11.2: OutOfMemoryError .............................................................................................................................. 139
Section 11.3: Registering own Handler for unexpected exceptions ...................................................................... 139
Section 11.4: UncaughtException .............................................................................................................................. 141
Section 11.5: NetworkOnMainThreadException ...................................................................................................... 141
Section 11.6: DexException ........................................................................................................................................ 143
Chapter 12: Getting Calculated View Dimensions .................................................................................... 144
Section 12.1: Calculating initial View dimensions in an Activity ............................................................................. 144
Chapter 13: AsyncTask ........................................................................................................................................... 145
Section 13.1: Basic Usage .......................................................................................................................................... 145
Section 13.2: Pass Activity as WeakReference to avoid memory leaks .............................................................. 147
Section 13.3: Download Image using AsyncTask in Android ................................................................................ 148
Section 13.4: Canceling AsyncTask .......................................................................................................................... 151
Section 13.5: AsyncTask: Serial Execution and Parallel Execution of Task .......................................................... 151
Section 13.6: Order of execution .............................................................................................................................. 154
Section 13.7: Publishing progress ............................................................................................................................. 154
Chapter 14: SharedPreferences ........................................................................................................................ 156
Section 14.1: Implementing a Settings screen using SharedPreferences ............................................................. 156
Section 14.2: Commit vs. Apply ................................................................................................................................ 158
Section 14.3: Read and write values to SharedPreferences .................................................................................. 158
Section 14.4: Retrieve all stored entries from a particular SharedPreferences file ............................................ 159
Section 14.5: Reading and writing data to SharedPreferences with Singleton ................................................... 160
Section 14.6: getPreferences(int) VS getSharedPreferences(String, int) ............................................................. 164
Section 14.7: Listening for SharedPreferences changes ....................................................................................... 164
Section 14.8: Store, Retrieve, Remove and Clear Data from SharedPreferences .............................................. 165
Section 14.9: Add filter for EditTextPreference ....................................................................................................... 165
Section 14.10: Supported data types in SharedPreferences ................................................................................. 166
Section 14.11: Dierent ways of instantiating an object of SharedPreferences .................................................. 166
Section 14.12: Removing keys ................................................................................................................................... 167
Section 14.13: Support pre-Honeycomb with StringSet ......................................................................................... 167
Chapter 15: Emulator .............................................................................................................................................. 169
Section 15.1: Taking screenshots .............................................................................................................................. 169
Section 15.2: Simulate call ......................................................................................................................................... 174
Section 15.3: Open the AVD Manager ..................................................................................................................... 174
Section 15.4: Resolving Errors while starting emulator ......................................................................................... 174
Chapter 16: Material Design ................................................................................................................................ 176
Section 16.1: Adding a Toolbar ................................................................................................................................. 176
Section 16.2: Buttons styled with Material Design .................................................................................................. 177
Section 16.3: Adding a FloatingActionButton (FAB) ............................................................................................... 178
Section 16.4: RippleDrawable ................................................................................................................................... 179
Section 16.5: Adding a TabLayout ........................................................................................................................... 184
Section 16.6: Bottom Sheets in Design Support Library ........................................................................................ 186
Section 16.7: Apply an AppCompat theme ............................................................................................................. 189
Section 16.8: Add a Snackbar ................................................................................................................................... 190
Section 16.9: Add a Navigation Drawer ................................................................................................................... 191
Section 16.10: How to use TextInputLayout ............................................................................................................. 194
Chapter 17: Lint Warnings .................................................................................................................................... 195
Section 17.1: Using tools:ignore in xml files ............................................................................................................. 195
Section 17.2: Configure LintOptions with gradle ..................................................................................................... 195
Section 17.3: Configuring lint checking in Java and XML source files .................................................................. 196
Section 17.4: How to configure the lint.xml file ....................................................................................................... 196
Section 17.5: Mark Suppress Warnings ................................................................................................................... 197
Section 17.6: Importing resources without "Deprecated" error ............................................................................ 197
Chapter 18: Service .................................................................................................................................................. 199
Section 18.1: Lifecycle of a Service ........................................................................................................................... 199
Section 18.2: Defining the process of a service ...................................................................................................... 200
Section 18.3: Creating an unbound service ............................................................................................................. 200
Section 18.4: Starting a Service ................................................................................................................................ 203
Section 18.5: Creating Bound Service with help of Binder ..................................................................................... 203
Section 18.6: Creating Remote Service (via AIDL) .................................................................................................. 204
Chapter 19: Storing Files in Internal & External Storage ...................................................................... 206
Section 19.1: Android: Internal and External Storage - Terminology Clarification .............................................. 206
Section 19.2: Using External Storage ....................................................................................................................... 210
Section 19.3: Using Internal Storage ........................................................................................................................ 211
Section 19.4: Fetch Device Directory : ..................................................................................................................... 211
Section 19.5: Save Database on SD Card (Backup DB on SD) ............................................................................. 213
Chapter 20: WebView ............................................................................................................................................. 215
Section 20.1: Troubleshooting WebView by printing console messages or by remote debugging ................. 215
Section 20.2: Communication from Javascript to Java (Android) ...................................................................... 216
Section 20.3: Communication from Java to Javascript ....................................................................................... 217
Section 20.4: Open dialer example ......................................................................................................................... 217
Section 20.5: Open Local File / Create dynamic content in Webview ................................................................ 218
Section 20.6: JavaScript alert dialogs in WebView - How to make them work ................................................. 218
Chapter 21: Project SDK versions ..................................................................................................................... 220
Section 21.1: Defining project SDK versions ............................................................................................................ 220
Chapter 22: RecyclerView .................................................................................................................................... 221
Section 22.1: Adding a RecyclerView ....................................................................................................................... 221
Section 22.2: Smoother loading of items ................................................................................................................ 222
Section 22.3: RecyclerView with DataBinding ........................................................................................................ 223
Section 22.4: Animate data change ........................................................................................................................ 224
Section 22.5: Popup menu with recyclerView ........................................................................................................ 228
Section 22.6: Using several ViewHolders with ItemViewType .............................................................................. 230
Section 22.7: Filter items inside RecyclerView with a SearchView ....................................................................... 231
Section 22.8: Drag&Drop and Swipe with RecyclerView ...................................................................................... 232
Section 22.9: Show default view till items load or when data is not available ................................................... 233
Section 22.10: Add header/footer to a RecyclerView ........................................................................................... 235
Section 22.11: Endless Scrolling in Recycleview ...................................................................................................... 238
Section 22.12: Add divider lines to RecyclerView items ......................................................................................... 238
Chapter 23: Google Maps API v2 for Android ............................................................................................. 241
Section 23.1: Custom Google Map Styles ................................................................................................................ 241
Section 23.2: Default Google Map Activity ............................................................................................................. 252
Section 23.3: Show Current Location in a Google Map ......................................................................................... 253
Section 23.4: Change Oset ..................................................................................................................................... 259
Section 23.5: MapView: embedding a GoogleMap in an existing layout ............................................................. 259
Section 23.6: Get debug SHA1 fingerprint ............................................................................................................... 261
Section 23.7: Adding markers to a map ................................................................................................................. 262
Section 23.8: UISettings ............................................................................................................................................ 262
Section 23.9: InfoWindow Click Listener ................................................................................................................. 263
Section 23.10: Obtaining the SH1-Fingerprint of your certificate keystore file ................................................... 264
Section 23.11: Do not launch Google Maps when the map is clicked (lite mode) ............................................... 265
Chapter 24: PorterDu Mode ............................................................................................................................ 266
Section 24.1: Creating a PorterDu ColorFilter ...................................................................................................... 266
Section 24.2: Creating a PorterDu XferMode ...................................................................................................... 266
Section 24.3: Apply a radial mask (vignette) to a bitmap using PorterDuXfermode ..................................... 266
Chapter 25: 9-Patch Images ............................................................................................................................... 268
Section 25.1: Basic rounded corners ....................................................................................................................... 268
Section 25.2: Optional padding lines ....................................................................................................................... 268
Section 25.3: Basic spinner ....................................................................................................................................... 269
Chapter 26: Android NDK ...................................................................................................................................... 270
Section 26.1: How to log in ndk ................................................................................................................................ 270
Section 26.2: Building native executables for Android .......................................................................................... 270
Section 26.3: How to clean the build ....................................................................................................................... 271
Section 26.4: How to use a makefile other than Android.mk ............................................................................... 271
Chapter 27: RecyclerView Decorations ......................................................................................................... 272
Section 27.1: Add divider to RecyclerView .............................................................................................................. 272
Section 27.2: Drawing a Separator ......................................................................................................................... 274
Section 27.3: How to add dividers using and DividerItemDecoration ................................................................. 275
Section 27.4: Per-item margins with ItemDecoration ............................................................................................ 275
Section 27.5: ItemOsetDecoration for GridLayoutManager in RecycleView ................................................... 276
Chapter 28: Camera 2 API .................................................................................................................................... 278
Section 28.1: Preview the main camera in a TextureView ..................................................................................... 278
Chapter 29: ViewPager .......................................................................................................................................... 287
Section 29.1: ViewPager with a dots indicator ........................................................................................................ 287
Section 29.2: Basic ViewPager usage with fragments .......................................................................................... 289
Section 29.3: ViewPager with PreferenceFragment .............................................................................................. 290
Section 29.4: Adding a ViewPager .......................................................................................................................... 291
Section 29.5: Setup OnPageChangeListener .......................................................................................................... 292
Section 29.6: ViewPager with TabLayout ............................................................................................................... 293
Chapter 30: CardView ............................................................................................................................................ 296
Section 30.1: Getting Started with CardView .......................................................................................................... 296
Section 30.2: Adding Ripple animation ................................................................................................................... 297
Section 30.3: Customizing the CardView ................................................................................................................ 297
Section 30.4: Using Images as Background in CardView (Pre-Lollipop device issues) ..................................... 298
Section 30.5: Animate CardView background color with TransitionDrawable ................................................... 300
Chapter 31: HttpURLConnection ....................................................................................................................... 301
Section 31.1: Creating an HttpURLConnection ........................................................................................................ 301
Section 31.2: Sending an HTTP GET request ........................................................................................................... 301
Section 31.3: Reading the body of an HTTP GET request ..................................................................................... 302
Section 31.4: Sending an HTTP POST request with parameters ........................................................................... 302
Section 31.5: A multi-purpose HttpURLConnection class to handle all types of HTTP requests ...................... 303
Section 31.6: Use HttpURLConnection for multipart/form-data .......................................................................... 306
Section 31.7: Upload (POST) file using HttpURLConnection ................................................................................. 309
Chapter 32: SQLite ................................................................................................................................................... 311
Section 32.1: onUpgrade() method .......................................................................................................................... 311
Section 32.2: Reading data from a Cursor ............................................................................................................. 311
Section 32.3: Using the SQLiteOpenHelper class ................................................................................................... 313
Section 32.4: Insert data into database .................................................................................................................. 314
Section 32.5: Bulk insert ............................................................................................................................................ 314
Section 32.6: Create a Contract, Helper and Provider for SQLite in Android ..................................................... 315
Section 32.7: Delete row(s) from the table ............................................................................................................. 319
Section 32.8: Updating a row in a table .................................................................................................................. 320
Section 32.9: Performing a Transaction ................................................................................................................. 320
Section 32.10: Create Database from assets folder .............................................................................................. 321
Section 32.11: Store image into SQLite .................................................................................................................... 323
Section 32.12: Exporting and importing a database .............................................................................................. 325
Chapter 33: ADB (Android Debug Bridge) .................................................................................................... 327
Section 33.1: Connect ADB to a device via WiFi ..................................................................................................... 327
Section 33.2: Direct ADB command to specific device in a multi-device setting ............................................... 329
Section 33.3: Taking a screenshot and video (for kitkat only) from a device display ....................................... 329
Section 33.4: Pull (push) files from (to) the device ................................................................................................ 330
Section 33.5: Print verbose list of connected devices ............................................................................................ 331
Section 33.6: View logcat .......................................................................................................................................... 331
Section 33.7: View and pull cache files of an app .................................................................................................. 332
Section 33.8: Clear application data ....................................................................................................................... 332
Section 33.9: View an app's internal data (data/data/<sample.package.id>) on a device .............................. 333
Section 33.10: Install and run an application .......................................................................................................... 333
Section 33.11: Sending broadcast ............................................................................................................................. 333
Section 33.12: Backup ................................................................................................................................................ 334
Section 33.13: View available devices ...................................................................................................................... 335
Section 33.14: Connect device by IP ........................................................................................................................ 335
Section 33.15: Install ADB on Linux system ............................................................................................................. 336
Section 33.16: View activity stack ............................................................................................................................. 336
Section 33.17: Reboot device .................................................................................................................................... 336
Section 33.18: Read device information .................................................................................................................. 337
Section 33.19: List all permissions that require runtime grant from users on Android 6.0 ................................ 337
Section 33.20: Turn on/o Wifi ................................................................................................................................ 337
Section 33.21: Start/stop adb ................................................................................................................................... 337
Chapter 34: ButterKnife ........................................................................................................................................ 338
Section 34.1: Configuring ButterKnife in your project ............................................................................................ 338
Section 34.2: Unbinding views in ButterKnife ......................................................................................................... 340
Section 34.3: Binding Listeners using ButterKnife .................................................................................................. 340
Section 34.4: Android Studio ButterKnife Plugin .................................................................................................... 341
Section 34.5: Binding Views using ButterKnife ....................................................................................................... 342
Chapter 35: Supporting Screens With Dierent Resolutions, Sizes ............................................... 345
Section 35.1: Using configuration qualifiers ............................................................................................................ 345
Section 35.2: Converting dp and sp to pixels ......................................................................................................... 345
Section 35.3: Text size and dierent android screen sizes ................................................................................... 346
Chapter 36: Glide ....................................................................................................................................................... 347
Section 36.1: Loading an image ............................................................................................................................... 347
Section 36.2: Add Glide to your project .................................................................................................................. 348
Section 36.3: Glide circle transformation (Load image in a circular ImageView) .............................................. 348
Section 36.4: Default transformations .................................................................................................................... 349
Section 36.5: Glide rounded corners image with custom Glide target ................................................................ 350
Section 36.6: Placeholder and Error handling ........................................................................................................ 350
Section 36.7: Preloading images .............................................................................................................................. 351
Section 36.8: Handling Glide image load failed ..................................................................................................... 351
Section 36.9: Load image in a circular ImageView without custom transformations ....................................... 352
Chapter 37: Retrofit2 .............................................................................................................................................. 353
Section 37.1: A Simple GET Request ......................................................................................................................... 353
Section 37.2: Debugging with Stetho ...................................................................................................................... 355
Section 37.3: Add logging to Retrofit2 .................................................................................................................... 356
Section 37.4: A simple POST request with GSON ................................................................................................... 356
Section 37.5: Download a file from Server using Retrofit2 ................................................................................... 358
Section 37.6: Upload multiple file using Retrofit as multipart .............................................................................. 360
Section 37.7: Retrofit with OkHttp interceptor ........................................................................................................ 363
Section 37.8: Header and Body: an Authentication Example ............................................................................... 363
Section 37.9: Uploading a file via Multipart ............................................................................................................ 364
Section 37.10: Retrofit 2 Custom Xml Converter .................................................................................................... 364
Section 37.11: Reading XML form URL with Retrofit 2 ............................................................................................ 366
Chapter 38: Dialog ................................................................................................................................................... 369
Section 38.1: Adding Material Design AlertDialog to your app using Appcompat ............................................. 369
Section 38.2: A Basic Alert Dialog ............................................................................................................................ 369
Section 38.3: ListView in AlertDialog ....................................................................................................................... 370
Section 38.4: Custom Alert Dialog with EditText .................................................................................................... 371
Section 38.5: DatePickerDialog ................................................................................................................................ 372
Section 38.6: DatePicker ........................................................................................................................................... 372
Section 38.7: Alert Dialog ......................................................................................................................................... 373
Section 38.8: Alert Dialog with Multi-line Title ........................................................................................................ 374
Section 38.9: Date Picker within DialogFragment ................................................................................................. 376
Section 38.10: Fullscreen Custom Dialog with no background and no title ........................................................ 378
Chapter 39: ACRA ...................................................................................................................................................... 380
Section 39.1: ACRAHandler ....................................................................................................................................... 380
Section 39.2: Example manifest ............................................................................................................................... 380
Section 39.3: Installation ........................................................................................................................................... 381
Chapter 40: GreenDAO .......................................................................................................................................... 382
Section 40.1: Helper methods for SELECT, INSERT, DELETE, UPDATE queries ................................................... 382
Section 40.2: Creating an Entity with GreenDAO 3.X that has a Composite Primary Key ................................ 384
Section 40.3: Getting started with GreenDao v3.X ................................................................................................. 385
Chapter 41: Formatting Strings ........................................................................................................................ 387
Section 41.1: Format a string resource .................................................................................................................... 387
Section 41.2: Formatting data types to String and vise versa .............................................................................. 387
Section 41.3: Format a timestamp to string ............................................................................................................ 387
Chapter 42: Notifications ..................................................................................................................................... 388
Section 42.1: Heads Up Notification with Ticker for older devices ....................................................................... 388
Section 42.2: Creating a simple Notification .......................................................................................................... 392
Section 42.3: Set custom notification - show full content text .............................................................................. 392
Section 42.4: Dynamically getting the correct pixel size for the large icon ........................................................ 393
Section 42.5: Ongoing notification with Action button .......................................................................................... 393
Section 42.6: Setting Dierent priorities in notification ......................................................................................... 394
Section 42.7: Set custom notification icon using `Picasso` library ........................................................................ 395
Section 42.8: Scheduling notifications ..................................................................................................................... 396
Chapter 43: AlarmManager ................................................................................................................................ 398
Section 43.1: How to Cancel an Alarm ..................................................................................................................... 398
Section 43.2: Creating exact alarms on all Android versions ............................................................................... 398
Section 43.3: API23+ Doze mode interferes with AlarmManager ........................................................................ 399
Section 43.4: Run an intent at a later time ............................................................................................................. 399
Chapter 44: Fragments ........................................................................................................................................ 400
Section 44.1: Pass data from Activity to Fragment using Bundle ........................................................................ 400
Section 44.2: The newInstance() pattern ................................................................................................................ 400
Section 44.3: Navigation between fragments using backstack and static fabric pattern ................................ 401
Section 44.4: Sending events back to an activity with callback interface .......................................................... 402
Section 44.5: Animate the transition between fragments .................................................................................... 403
Section 44.6: Communication between Fragments ............................................................................................... 404
Chapter 45: Handler ............................................................................................................................................... 409
Section 45.1: HandlerThreads and communication between Threads ................................................................ 409
Section 45.2: Use Handler to create a Timer (similar to javax.swing.Timer) ...................................................... 409
Section 45.3: Using a Handler to execute code after a delayed amount of time .............................................. 410
Section 45.4: Stop handler from execution ............................................................................................................ 411
Chapter 46: Creating Custom Views ............................................................................................................... 412
Section 46.1: Creating Custom Views ...................................................................................................................... 412
Section 46.2: Adding attributes to views ................................................................................................................. 414
Section 46.3: CustomView performance tips ......................................................................................................... 416
Section 46.4: Creating a compound view ............................................................................................................... 417
Section 46.5: Compound view for SVG/VectorDrawable as drawableRight ...................................................... 420
Section 46.6: Responding to Touch Events ............................................................................................................ 423
Chapter 47: BroadcastReceiver ....................................................................................................................... 424
Section 47.1: Using LocalBroadcastManager ......................................................................................................... 424
Section 47.2: BroadcastReceiver Basics ................................................................................................................. 424
Section 47.3: Introduction to Broadcast receiver ................................................................................................... 425
Section 47.4: Using ordered broadcasts ................................................................................................................. 425
Section 47.5: Sticky Broadcast ................................................................................................................................. 426
Section 47.6: Enabling and disabling a Broadcast Receiver programmatically ................................................ 426
Section 47.7: Example of a LocalBroadcastManager ........................................................................................... 427
Section 47.8: Android stopped state ....................................................................................................................... 428
Section 47.9: Communicate two activities through custom Broadcast receiver ................................................ 428
Section 47.10: BroadcastReceiver to handle BOOT_COMPLETED events .......................................................... 429
Section 47.11: Bluetooth Broadcast receiver ........................................................................................................... 430
Chapter 48: Activity ................................................................................................................................................ 431
Section 48.1: Activity launchMode ............................................................................................................................ 431
Section 48.2: Exclude an activity from back-stack history ................................................................................... 432
Section 48.3: Android Activity LifeCycle Explained ................................................................................................ 432
Section 48.4: End Application with exclude from Recents .................................................................................... 435
Section 48.5: Presenting UI with setContentView .................................................................................................. 436
Section 48.6: Up Navigation for Activities ............................................................................................................... 437
Section 48.7: Clear your current Activity stack and launch a new Activity ......................................................... 438
Chapter 49: Snackbar ............................................................................................................................................ 440
Section 49.1: Creating a simple Snackbar ............................................................................................................... 440
Section 49.2: Custom Snack Bar .............................................................................................................................. 440
Section 49.3: Custom Snackbar (no need view) .................................................................................................... 441
Section 49.4: Snackbar with Callback ..................................................................................................................... 442
Section 49.5: Snackbar vs Toasts: Which one should I use? ................................................................................. 442
Section 49.6: Custom Snackbar ............................................................................................................................... 443
Chapter 50: Runtime Permissions in API-23 + ............................................................................................ 444
Section 50.1: Android 6.0 multiple permissions ...................................................................................................... 444
Section 50.2: Multiple Runtime Permissions From Same Permission Groups ..................................................... 445
Section 50.3: Using PermissionUtil .......................................................................................................................... 446
Section 50.4: Include all permission-related code to an abstract base class and extend the activity of this
base class to achieve cleaner/reusable code ............................................................................................... 447
Section 50.5: Enforcing Permissions in Broadcasts, URI ....................................................................................... 449
Chapter 51: Logging and using Logcat .......................................................................................................... 451
Section 51.1: Filtering the logcat output ................................................................................................................... 451
Section 51.2: Logging ................................................................................................................................................ 452
Section 51.3: Using the Logcat ................................................................................................................................. 454
Section 51.4: Log with link to source directly from Logcat ................................................................................... 455
Section 51.5: Clear logs ............................................................................................................................................. 455
Section 51.6: Android Studio usage ......................................................................................................................... 455
Section 51.7: Generating Logging code ................................................................................................................... 456
Chapter 52: VectorDrawable and AnimatedVectorDrawable .......................................................... 458
Section 52.1: Basic VectorDrawable ........................................................................................................................ 458
Section 52.2: <group> tags ....................................................................................................................................... 458
Section 52.3: Basic AnimatedVectorDrawable ....................................................................................................... 459
Section 52.4: Using Strokes ...................................................................................................................................... 460
Section 52.5: Using <clip-path> ................................................................................................................................ 462
Section 52.6: Vector compatibility through AppCompat ...................................................................................... 462
Chapter 53: Tools Attributes ............................................................................................................................... 464
Section 53.1: Designtime Layout Attributes ............................................................................................................ 464
Chapter 54: Toast .................................................................................................................................................... 465
Section 54.1: Creating a custom Toast .................................................................................................................... 465
Section 54.2: Set position of a Toast ....................................................................................................................... 466
Section 54.3: Showing a Toast Message ................................................................................................................. 466
Section 54.4: Show Toast Message Above Soft Keyboard ................................................................................... 467
Section 54.5: Thread safe way of displaying Toast (Application Wide) ............................................................. 467
Section 54.6: Thread safe way of displaying a Toast Message (For AsyncTask) ............................................. 468
Chapter 55: Interfaces ........................................................................................................................................... 469
Section 55.1: Custom Listener ................................................................................................................................... 469
Section 55.2: Basic Listener ...................................................................................................................................... 470
Chapter 56: Animators ........................................................................................................................................... 472
Section 56.1: TransitionDrawable animation .......................................................................................................... 472
Section 56.2: Fade in/out animation ....................................................................................................................... 472
Section 56.3: ValueAnimator .................................................................................................................................... 473
Section 56.4: Expand and Collapse animation of View ......................................................................................... 474
Section 56.5: ObjectAnimator .................................................................................................................................. 475
Section 56.6: ViewPropertyAnimator ...................................................................................................................... 475
Section 56.7: Shake animation of an ImageView .................................................................................................. 476
Chapter 57: Location .............................................................................................................................................. 478
Section 57.1: Fused location API ............................................................................................................................... 478
Section 57.2: Get Address From Location using Geocoder .................................................................................. 482
Section 57.3: Requesting location updates using LocationManager ................................................................... 483
Section 57.4: Requesting location updates on a separate thread using LocationManager ............................. 484
Section 57.5: Getting location updates in a BroadcastReceiver .......................................................................... 485
Section 57.6: Register geofence .............................................................................................................................. 486
Chapter 58: Theme, Style, Attribute ............................................................................................................... 490
Section 58.1: Define primary, primary dark, and accent colors ........................................................................... 490
Section 58.2: Multiple Themes in one App .............................................................................................................. 490
Section 58.3: Navigation Bar Color (API 21+) ......................................................................................................... 492
Section 58.4: Use Custom Theme Per Activity ....................................................................................................... 492
Section 58.5: Light Status Bar (API 23+) ................................................................................................................. 493
Section 58.6: Use Custom Theme Globally ............................................................................................................. 493
Section 58.7: Overscroll Color (API 21+) .................................................................................................................. 493
Section 58.8: Ripple Color (API 21+) ......................................................................................................................... 493
Section 58.9: Translucent Navigation and Status Bars (API 19+) ......................................................................... 494
Section 58.10: Theme inheritance ............................................................................................................................ 494
Chapter 59: The Manifest File ............................................................................................................................ 495
Section 59.1: Declaring Components ....................................................................................................................... 495
Section 59.2: Declaring permissions in your manifest file .................................................................................... 495
Chapter 60: Parcelable .......................................................................................................................................... 497
Section 60.1: Making a custom object Parcelable .................................................................................................. 497
Section 60.2: Parcelable object containing another Parcelable object ............................................................... 498
Section 60.3: Using Enums with Parcelable ............................................................................................................ 499
Chapter 61: MediaPlayer ....................................................................................................................................... 501
Section 61.1: Basic creation and playing ................................................................................................................. 501
Section 61.2: Media Player with Buer progress and play position ..................................................................... 501
Section 61.3: Getting system ringtones ................................................................................................................... 503
Section 61.4: Asynchronous prepare ....................................................................................................................... 504
Section 61.5: Import audio into androidstudio and play it .................................................................................... 504
Section 61.6: Getting and setting system volume .................................................................................................. 506
Chapter 62: Multidex and the Dex Method Limit ...................................................................................... 508
Section 62.1: Enabling Multidex ................................................................................................................................ 508
Section 62.2: Multidex by extending Application ................................................................................................... 509
Section 62.3: Multidex by extending MultiDexApplication ..................................................................................... 509
Section 62.4: Multidex by using MultiDexApplication directly ............................................................................... 510
Section 62.5: Counting Method References On Every Build (Dexcount Gradle Plugin) ..................................... 510
Chapter 63: Data Synchronization with Sync Adapter .......................................................................... 512
Section 63.1: Dummy Sync Adapter with Stub Provider ........................................................................................ 512
Chapter 64: Menu ..................................................................................................................................................... 518
Section 64.1: Options menu with dividers ................................................................................................................ 518
Section 64.2: Apply custom font to Menu ............................................................................................................... 518
Section 64.3: Creating a Menu in an Activity .......................................................................................................... 519
Chapter 65: Instant Run in Android Studio .................................................................................................. 522
Section 65.1: Enabling or disabling Instant Run ...................................................................................................... 522
Section 65.2: Types of code Swaps in Instant Run ................................................................................................ 522
Section 65.3: Unsupported code changes when using Instant Run ..................................................................... 523
Chapter 66: Picasso ................................................................................................................................................. 524
Section 66.1: Adding Picasso Library to your Android Project .............................................................................. 524
Section 66.2: Circular Avatars with Picasso ............................................................................................................ 524
Section 66.3: Placeholder and Error Handling ....................................................................................................... 526
Section 66.4: Re-sizing and Rotating ...................................................................................................................... 526
Section 66.5: Disable cache in Picasso .................................................................................................................... 527
Section 66.6: Using Picasso as ImageGetter for Html.fromHtml ......................................................................... 527
Section 66.7: Cancelling Image Requests using Picasso ....................................................................................... 528
Section 66.8: Loading Image from external Storage ............................................................................................ 529
Section 66.9: Downloading image as Bitmap using Picasso ................................................................................ 529
Section 66.10: Try oine disk cache first, then go online and fetch the image ................................................. 529
Chapter 67: Bluetooth and Bluetooth LE API ............................................................................................. 531
Section 67.1: Permissions .......................................................................................................................................... 531
Section 67.2: Check if bluetooth is enabled ............................................................................................................ 531
Section 67.3: Find nearby Bluetooth Low Energy devices .................................................................................... 531
Section 67.4: Make device discoverable ................................................................................................................. 536
Section 67.5: Connect to Bluetooth device ............................................................................................................. 536
Section 67.6: Find nearby bluetooth devices .......................................................................................................... 538
Chapter 68: RoboGuice .......................................................................................................................................... 539
Section 68.1: Simple example ................................................................................................................................... 539
Section 68.2: Installation for Gradle Projects ......................................................................................................... 539
Section 68.3: @ContentView annotation ................................................................................................................ 539
Section 68.4: @InjectResource annotation ............................................................................................................. 539
Section 68.5: @InjectView annotation ..................................................................................................................... 540
Section 68.6: Introduction to RoboGuice ................................................................................................................ 540
Chapter 69: Memory Leaks ................................................................................................................................. 543
Section 69.1: Avoid leaking Activities with AsyncTask ........................................................................................... 543
Section 69.2: Common memory leaks and how to fix them ................................................................................ 544
Section 69.3: Detect memory leaks with the LeakCanary library ........................................................................ 545
Section 69.4: Anonymous callback in activities ...................................................................................................... 545
Section 69.5: Activity Context in static classes ....................................................................................................... 546
Section 69.6: Avoid leaking Activities with Listeners .............................................................................................. 547
Section 69.7: Avoid memory leaks with Anonymous Class, Handler, Timer Task, Thread ............................... 552
Chapter 70: Universal Image Loader ............................................................................................................. 554
Section 70.1: Basic usage .......................................................................................................................................... 554
Section 70.2: Initialize Universal Image Loader ..................................................................................................... 554
Chapter 71: Volley .................................................................................................................................................... 555
Section 71.1: Using Volley for HTTP requests .......................................................................................................... 555
Section 71.2: Basic StringRequest using GET method ........................................................................................... 556
Section 71.3: Adding custom design time attributes to NetworkImageView ....................................................... 557
Section 71.4: Adding custom headers to your requests [e.g. for basic auth] ..................................................... 558
Section 71.5: Remote server authentication using StringRequest through POST method ................................ 559
Section 71.6: Cancel a request .................................................................................................................................. 561
Section 71.7: Request JSON ...................................................................................................................................... 561
Section 71.8: Use JSONArray as request body ...................................................................................................... 561
Section 71.9: Boolean variable response from server with json request in volley .............................................. 562
Section 71.10: Helper Class for Handling Volley Errors .......................................................................................... 563
Chapter 72: Widgets ................................................................................................................................................ 565
Section 72.1: Manifest Declaration - ........................................................................................................................ 565
Section 72.2: Metadata ............................................................................................................................................. 565
Section 72.3: AppWidgetProvider Class .................................................................................................................. 565
Section 72.4: Create/Integrate Basic Widget using Android Studio .................................................................... 566
Section 72.5: Two widgets with dierent layouts declaration .............................................................................. 567
Chapter 73: Date and Time Pickers ................................................................................................................. 569
Section 73.1: Date Picker Dialog ............................................................................................................................... 569
Section 73.2: Material DatePicker ............................................................................................................................ 569
Chapter 74: Integrate Google Sign In ............................................................................................................ 572
Section 74.1: Google Sign In with Helper class ....................................................................................................... 572
Chapter 75: In-app Billing ..................................................................................................................................... 575
Section 75.1: Consumable In-app Purchases .......................................................................................................... 575
Section 75.2: (Third party) In-App v3 Library ......................................................................................................... 579
Chapter 76: FloatingActionButton ................................................................................................................... 581
Section 76.1: How to add the FAB to the layout ..................................................................................................... 581
Section 76.2: Show and Hide FloatingActionButton on Swipe .............................................................................. 582
Section 76.3: Show and Hide FloatingActionButton on Scroll ............................................................................... 584
Section 76.4: Setting behaviour of FloatingActionButton ..................................................................................... 586
Chapter 77: ContentProvider ............................................................................................................................. 587
Section 77.1: Implementing a basic content provider class .................................................................................. 587
Chapter 78: Dagger 2 ............................................................................................................................................. 591
Section 78.1: Component setup for Application and Activity injection ................................................................. 591
Section 78.2: Custom Scopes ................................................................................................................................... 592
Section 78.3: Using @Subcomponent instead of @Component(dependencies={...}) ........................................ 593
Section 78.4: Creating a component from multiple modules ............................................................................... 593
Section 78.5: How to add Dagger 2 in build.gradle ............................................................................................... 594
Section 78.6: Constructor Injection .......................................................................................................................... 595
Chapter 79: Realm ................................................................................................................................................... 597
Section 79.1: Sorted queries ...................................................................................................................................... 597
Section 79.2: Using Realm with RxJava .................................................................................................................. 597
Section 79.3: Basic Usage ......................................................................................................................................... 598
Section 79.4: List of primitives (RealmList<Integer/String/...>) ............................................................................ 601
Section 79.5: Async queries ...................................................................................................................................... 602
Section 79.6: Adding Realm to your project ........................................................................................................... 602
Section 79.7: Realm Models ..................................................................................................................................... 602
Section 79.8: try-with-resources .............................................................................................................................. 603
Chapter 80: Unit testing in Android with JUnit .......................................................................................... 604
Section 80.1: Moving Business Logic Out of Android Componenets .................................................................... 604
Section 80.2: Creating Local unit tests .................................................................................................................... 606
Section 80.3: Getting started with JUnit ................................................................................................................. 607
Section 80.4: Exceptions ........................................................................................................................................... 610
Section 80.5: Static import ....................................................................................................................................... 611
Chapter 81: Android Versions ............................................................................................................................. 612
Section 81.1: Checking the Android Version on device at runtime ........................................................................ 612
Chapter 82: Wi-Fi Connections ........................................................................................................................... 613
Section 82.1: Connect with WEP encryption ........................................................................................................... 613
Section 82.2: Connect with WPA2 encryption ........................................................................................................ 613
Section 82.3: Scan for access points ....................................................................................................................... 614
Chapter 83: SensorManager ............................................................................................................................... 616
Section 83.1: Decide if your device is static or not, using the accelerometer ..................................................... 616
Section 83.2: Retrieving sensor events ................................................................................................................... 616
Section 83.3: Sensor transformation to world coordinate system ...................................................................... 617
Chapter 84: Localization with resources in Android .............................................................................. 619
Section 84.1: Configuration types and qualifier names for each folder under the "res" directory .................. 619
Section 84.2: Adding translation to your Android app .......................................................................................... 620
Section 84.3: Type of resource directories under the "res" folder ....................................................................... 622
Section 84.4: Change locale of android application programmatically ............................................................. 622
Section 84.5: Currency .............................................................................................................................................. 625
Chapter 85: ProgressBar ...................................................................................................................................... 626
Section 85.1: Material Linear ProgressBar .............................................................................................................. 626
Section 85.2: Tinting ProgressBar ........................................................................................................................... 628
Section 85.3: Customized progressbar ................................................................................................................... 628
Section 85.4: Creating Custom Progress Dialog .................................................................................................... 630
Section 85.5: Indeterminate ProgressBar ............................................................................................................... 632
Section 85.6: Determinate ProgressBar .................................................................................................................. 633
Chapter 86: Custom Fonts ................................................................................................................................... 635
Section 86.1: Custom font in canvas text ................................................................................................................ 635
Section 86.2: Working with fonts in Android O ....................................................................................................... 635
Section 86.3: Custom font to whole activity ........................................................................................................... 636
Section 86.4: Putting a custom font in your app .................................................................................................... 636
Section 86.5: Initializing a font ................................................................................................................................. 636
Section 86.6: Using a custom font in a TextView ................................................................................................... 636
Section 86.7: Apply font on TextView by xml (Not required Java code) ............................................................ 637
Section 86.8: Ecient Typeface loading ................................................................................................................ 638
Chapter 87: Vibration ............................................................................................................................................. 639
Section 87.1: Getting Started with Vibration ........................................................................................................... 639
Section 87.2: Vibrate Indefinitely ............................................................................................................................. 639
Section 87.3: Vibration Patterns ............................................................................................................................... 639
Section 87.4: Stop Vibrate ........................................................................................................................................ 640
Section 87.5: Vibrate for one time ........................................................................................................................... 640
Chapter 88: Google Awareness APIs ............................................................................................................... 641
Section 88.1: Get changes for location within a certain range using Fence API ................................................. 641
Section 88.2: Get current location using Snapshot API ......................................................................................... 642
Section 88.3: Get changes in user activity with Fence API .................................................................................... 642
Section 88.4: Get current user activity using Snapshot API .................................................................................. 643
Section 88.5: Get headphone state with Snapshot API ......................................................................................... 643
Section 88.6: Get nearby places using Snapshot API ............................................................................................ 644
Section 88.7: Get current weather using Snapshot API ......................................................................................... 644
Chapter 89: Text to Speech(TTS) ..................................................................................................................... 645
Section 89.1: Text to Speech Base ........................................................................................................................... 645
Section 89.2: TextToSpeech implementation across the APIs ............................................................................. 646
Chapter 90: UI Lifecycle ........................................................................................................................................ 650
Section 90.1: Saving data on memory trimming .................................................................................................... 650
Chapter 91: Spinner .................................................................................................................................................. 651
Section 91.1: Basic Spinner Example ........................................................................................................................ 651
Section 91.2: Adding a spinner to your activity ...................................................................................................... 652
Chapter 92: Data Encryption/Decryption ................................................................................................... 654
Section 92.1: AES encryption of data using password in a secure way .............................................................. 654
Chapter 93: Testing UI with Espresso ............................................................................................................. 656
Section 93.1: Overall Espresso .................................................................................................................................. 656
Section 93.2: Espresso simple UI test ...................................................................................................................... 658
Section 93.3: Open Close DrawerLayout ................................................................................................................ 661
Section 93.4: Set Up Espresso .................................................................................................................................. 662
Section 93.5: Performing an action on a view ........................................................................................................ 663
Section 93.6: Finding a view with onView ............................................................................................................... 663
Section 93.7: Create Espresso Test Class ............................................................................................................... 663
Section 93.8: Up Navigation ..................................................................................................................................... 664
Section 93.9: Group a collection of test classes in a test suite ............................................................................. 664
Section 93.10: Espresso custom matchers .............................................................................................................. 665
Chapter 94: Writing UI tests - Android .......................................................................................................... 668
Section 94.1: MockWebServer example .................................................................................................................. 668
Section 94.2: IdlingResource .................................................................................................................................... 670
Chapter 95: GreenRobot EventBus .................................................................................................................. 674
Section 95.1: Passing a Simple Event ....................................................................................................................... 674
Section 95.2: Receiving Events ................................................................................................................................ 675
Section 95.3: Sending Events ................................................................................................................................... 675
Chapter 96: OkHttp .................................................................................................................................................. 676
Section 96.1: Basic usage example .......................................................................................................................... 676
Section 96.2: Setting up OkHttp ............................................................................................................................... 676
Section 96.3: Logging interceptor ............................................................................................................................ 676
Section 96.4: Synchronous Get Call ......................................................................................................................... 677
Section 96.5: Asynchronous Get Call ....................................................................................................................... 677
Section 96.6: Posting form parameters .................................................................................................................. 678
Section 96.7: Posting a multipart request ............................................................................................................... 678
Section 96.8: Rewriting Responses .......................................................................................................................... 678
Chapter 97: Enhancing Android Performance Using Icon Fonts ...................................................... 680
Section 97.1: How to integrate Icon fonts ............................................................................................................... 680
Section 97.2: TabLayout with icon fonts ................................................................................................................. 682
Chapter 98: Handling Deep Links ..................................................................................................................... 684
Section 98.1: Retrieving query parameters ............................................................................................................ 684
Section 98.2: Simple deep link ................................................................................................................................. 684
Section 98.3: Multiple paths on a single domain .................................................................................................... 685
Section 98.4: Multiple domains and multiple paths ............................................................................................... 685
Section 98.5: Both http and https for the same domain ....................................................................................... 686
Section 98.6: Using pathPrefix ................................................................................................................................. 686
Chapter 99: Canvas drawing using SurfaceView ..................................................................................... 687
Section 99.1: SurfaceView with drawing thread ..................................................................................................... 687
Chapter 100: Firebase ............................................................................................................................................ 692
Section 100.1: Add Firebase to Your Android Project ............................................................................................. 692
Section 100.2: Updating a Firebase users's email .................................................................................................. 693
Section 100.3: Create a Firebase user ..................................................................................................................... 694
Section 100.4: Change Password ............................................................................................................................. 695
Section 100.5: Firebase Cloud Messaging ............................................................................................................... 696
Section 100.6: Firebase Storage Operations .......................................................................................................... 698
Section 100.7: Firebase Realtime Database: how to set/get data ....................................................................... 704
Section 100.8: Demo of FCM based notifications ................................................................................................... 705
Section 100.9: Sign In Firebase user with email and password ............................................................................ 715
Section 100.10: Send Firebase password reset email ............................................................................................ 716
Section 100.11: Re-Authenticate Firebase user ....................................................................................................... 718
Section 100.12: Firebase Sign Out ............................................................................................................................ 719
Chapter 101: Crash Reporting Tools ................................................................................................................ 720
Section 101.1: Fabric - Crashlytics ............................................................................................................................. 720
Section 101.2: Capture crashes using Sherlock ....................................................................................................... 725
Section 101.3: Force a Test Crash With Fabric ........................................................................................................ 726
Section 101.4: Crash Reporting with ACRA .............................................................................................................. 727
Chapter 102: Check Internet Connectivity ................................................................................................... 729
Section 102.1: Check if device has internet connectivity ........................................................................................ 729
Section 102.2: How to check network strength in android? .................................................................................. 729
Section 102.3: How to check network strength ...................................................................................................... 730
Chapter 103: Facebook SDK for Android ...................................................................................................... 733
Section 103.1: How to add Facebook Login in Android .......................................................................................... 733
Section 103.2: Create your own custom button for Facebook login .................................................................... 735
Section 103.3: A minimalistic guide to Facebook login/signup implementation ................................................ 736
Section 103.4: Setting permissions to access data from the Facebook profile .................................................. 737
Section 103.5: Logging out of Facebook ................................................................................................................. 737
Chapter 104: Unzip File in Android ................................................................................................................... 738
Section 104.1: Unzip file ............................................................................................................................................. 738
Chapter 105: Android Places API ....................................................................................................................... 739
Section 105.1: Getting Current Places by Using Places API ................................................................................... 739
Section 105.2: Place Autocomplete Integration ..................................................................................................... 740
Section 105.3: Place Picker Usage Example ........................................................................................................... 741
Section 105.4: Setting place type filters for PlaceAutocomplete .......................................................................... 742
Section 105.5: Adding more than one google auto complete activity ................................................................. 743
Chapter 106: Creating your own libraries for Android applications .............................................. 745
Section 106.1: Create a library available on Jitpack.io .......................................................................................... 745
Section 106.2: Creating library project .................................................................................................................... 745
Section 106.3: Using library in project as a module ............................................................................................... 746
Chapter 107: Gson .................................................................................................................................................... 747
Section 107.1: Parsing JSON with Gson ................................................................................................................... 747
Section 107.2: Adding a custom Converter to Gson .............................................................................................. 749
Section 107.3: Parsing a List<String> with Gson ..................................................................................................... 749
Section 107.4: Adding Gson to your project ............................................................................................................ 750
Section 107.5: Parsing JSON to Generic Class Object with Gson ......................................................................... 750
Section 107.6: Using Gson with inheritance ............................................................................................................. 751
Section 107.7: Parsing JSON property to enum with Gson ................................................................................... 753
Section 107.8: Using Gson to load a JSON file from disk ...................................................................................... 753
Section 107.9: Using Gson as serializer with Retrofit ............................................................................................. 753
Section 107.10: Parsing json array to generic class using Gson ........................................................................... 754
Section 107.11: Custom JSON Deserializer using Gson ........................................................................................... 755
Section 107.12: JSON Serialization/Deserialization with AutoValue and Gson ................................................... 756
Chapter 108: Device Display Metrics ............................................................................................................... 758
Section 108.1: Get the screens pixel dimensions ..................................................................................................... 758
Section 108.2: Get screen density ............................................................................................................................ 758
Section 108.3: Formula px to dp, dp to px conversation ....................................................................................... 758
Chapter 109: TextView ............................................................................................................................................ 759
Section 109.1: Spannable TextView .......................................................................................................................... 759
Section 109.2: Strikethrough TextView .................................................................................................................... 760
Section 109.3: TextView with image ......................................................................................................................... 761
Section 109.4: Make RelativeSizeSpan align to top ............................................................................................... 761
Section 109.5: Pinchzoom on TextView ................................................................................................................... 763
Section 109.6: Textview with dierent Textsize ...................................................................................................... 764
Section 109.7: Theme and Style customization ...................................................................................................... 764
Section 109.8: TextView customization ................................................................................................................... 766
Section 109.9: Single TextView with two dierent colors ...................................................................................... 769
Chapter 110: ListView .............................................................................................................................................. 771
Section 110.1: Custom ArrayAdapter ........................................................................................................................ 771
Section 110.2: A basic ListView with an ArrayAdapter ........................................................................................... 772
Section 110.3: Filtering with CursorAdapter ............................................................................................................. 772
Chapter 111: Building Backwards Compatible Apps ................................................................................. 774
Section 111.1: How to handle deprecated API .......................................................................................................... 774
Chapter 112: Loader ................................................................................................................................................. 776
Section 112.1: Basic AsyncTaskLoader ..................................................................................................................... 776
Section 112.2: AsyncTaskLoader with cache ........................................................................................................... 777
Section 112.3: Reloading ............................................................................................................................................ 778
Section 112.4: Pass parameters using a Bundle ..................................................................................................... 779
Chapter 113: ProGuard - Obfuscating and Shrinking your code ....................................................... 780
Section 113.1: Rules for some of the widely used Libraries .................................................................................... 780
Section 113.2: Remove trace logging (and other) statements at build time ....................................................... 782
Section 113.3: Protecting your code from hackers ................................................................................................. 782
Section 113.4: Enable ProGuard for your build ........................................................................................................ 783
Section 113.5: Enabling ProGuard with a custom obfuscation configuration file ................................................ 783
Chapter 114: Detect Shake Event in Android .............................................................................................. 785
Section 114.1: Shake Detector in Android Example ................................................................................................. 785
Section 114.2: Using Seismic shake detection ......................................................................................................... 786
Chapter 115: Typedef Annotations: @IntDef, @StringDef ................................................................... 787
Section 115.1: IntDef Annotations .............................................................................................................................. 787
Section 115.2: Combining constants with flags ....................................................................................................... 787
Chapter 116: Capturing Screenshots ............................................................................................................... 789
Section 116.1: Taking a screenshot of a particular view ......................................................................................... 789
Section 116.2: Capturing Screenshot via Android Studio ....................................................................................... 789
Section 116.3: Capturing Screenshot via ADB and saving directly in your PC ..................................................... 790
Section 116.4: Capturing Screenshot via Android Device Monitor ........................................................................ 790
Section 116.5: Capturing Screenshot via ADB ......................................................................................................... 791
Chapter 117: MVP Architecture ........................................................................................................................... 792
Section 117.1: Login example in the Model View Presenter (MVP) pattern .......................................................... 792
Section 117.2: Simple Login Example in MVP .......................................................................................................... 795
Chapter 118: Orientation Changes .................................................................................................................... 802
Section 118.1: Saving and Restoring Activity State ................................................................................................. 802
Section 118.2: Retaining Fragments ......................................................................................................................... 802
Section 118.3: Manually Managing Configuration Changes .................................................................................. 803
Section 118.4: Handling AsyncTask .......................................................................................................................... 804
Section 118.5: Lock Screen's rotation programmatically ....................................................................................... 805
Section 118.6: Saving and Restoring Fragment State ............................................................................................ 806
Chapter 119: Xposed ................................................................................................................................................ 808
Section 119.1: Creating a Xposed Module ................................................................................................................ 808
Section 119.2: Hooking a method ............................................................................................................................. 808
Chapter 120: Security .............................................................................................................................................. 810
Section 120.1: Verifying App Signature - Tamper Detection ................................................................................. 810
Chapter 121: PackageManager .......................................................................................................................... 811
Section 121.1: Retrieve application version .............................................................................................................. 811
Section 121.2: Version name and version code ...................................................................................................... 811
Section 121.3: Install time and update time ............................................................................................................. 811
Section 121.4: Utility method using PackageManager ........................................................................................... 812
Chapter 122: ImageView ........................................................................................................................................ 814
Section 122.1: Set tint ................................................................................................................................................. 814
Section 122.2: Set alpha ............................................................................................................................................ 815
Section 122.3: Set Scale Type ................................................................................................................................... 815
Section 122.4: ImageView ScaleType - Center ....................................................................................................... 820
Section 122.5: ImageView ScaleType - CenterCrop ............................................................................................... 822
Section 122.6: ImageView ScaleType - CenterInside ............................................................................................. 824
Section 122.7: ImageView ScaleType - FitStart and FitEnd .................................................................................. 826
Section 122.8: ImageView ScaleType - FitCenter ................................................................................................... 830
Section 122.9: Set Image Resource .......................................................................................................................... 832
Section 122.10: ImageView ScaleType - FitXy ........................................................................................................ 833
Section 122.11: MLRoundedImageView.java ............................................................................................................ 835
Chapter 123: Gesture Detection ......................................................................................................................... 838
Section 123.1: Swipe Detection .................................................................................................................................. 838
Section 123.2: Basic Gesture Detection ................................................................................................................... 839
Chapter 124: Doze Mode ....................................................................................................................................... 841
Section 124.1: Whitelisting an Android application programmatically ................................................................. 841
Section 124.2: Exclude app from using doze mode ............................................................................................... 841
Chapter 125: Android Sound and Media ........................................................................................................ 842
Section 125.1: How to pick image and video for api >19 ........................................................................................ 842
Section 125.2: Play sounds via SoundPool .............................................................................................................. 843
Chapter 126: SearchView ...................................................................................................................................... 844
Section 126.1: Setting Theme for SearchView ......................................................................................................... 844
Section 126.2: SearchView in Toolbar with Fragment ........................................................................................... 844
Section 126.3: Appcompat SearchView with RxBindings watcher ........................................................................ 846
Chapter 127: Camera and Gallery .................................................................................................................... 849
Section 127.1: Take photo .......................................................................................................................................... 849
Section 127.2: Taking full-sized photo from camera ............................................................................................. 851
Section 127.3: Decode bitmap correctly rotated from the uri fetched with the intent ....................................... 854
Section 127.4: Set camera resolution ....................................................................................................................... 856
Section 127.5: How to start camera or gallery and save camera result to storage .......................................... 856
Chapter 128: Callback URL ................................................................................................................................... 860
Section 128.1: Callback URL example with Instagram OAuth ............................................................................... 860
Chapter 129: Twitter APIs ...................................................................................................................................... 861
Section 129.1: Creating login with twitter button and attach a callback to it ...................................................... 861
Chapter 130: Drawables ........................................................................................................................................ 863
Section 130.1: Custom Drawable .............................................................................................................................. 863
Section 130.2: Tint a drawable ................................................................................................................................. 864
Section 130.3: Circular View ...................................................................................................................................... 865
Section 130.4: Make View with rounded corners .................................................................................................... 865
Chapter 131: Colors ................................................................................................................................................... 867
Section 131.1: Color Manipulation .............................................................................................................................. 867
Chapter 132: ConstraintLayout .......................................................................................................................... 868
Section 132.1: Adding ConstraintLayout to your project ....................................................................................... 868
Section 132.2: Chains ................................................................................................................................................. 869
Chapter 133: RenderScript ................................................................................................................................... 870
Section 133.1: Getting Started ................................................................................................................................... 870
Section 133.2: Blur a View ......................................................................................................................................... 876
Section 133.3: Blur an image .................................................................................................................................... 878
Chapter 134: Fresco ................................................................................................................................................. 881
Section 134.1: Getting Started with Fresco .............................................................................................................. 881
Section 134.2: Using OkHttp 3 with Fresco .............................................................................................................. 882
Section 134.3: JPEG Streaming with Fresco using DraweeController .................................................................. 882
Chapter 135: Swipe to Refresh ........................................................................................................................... 883
Section 135.1: How to add Swipe-to-Refresh To your app .................................................................................... 883
Section 135.2: Swipe To Refresh with RecyclerView .............................................................................................. 883
Chapter 136: AutoCompleteTextView ............................................................................................................. 885
Section 136.1: AutoComplete with CustomAdapter, ClickListener and Filter ....................................................... 885
Section 136.2: Simple, hard-coded AutoCompleteTextView ................................................................................. 888
Chapter 137: Installing apps with ADB ........................................................................................................... 889
Section 137.1: Uninstall an app ................................................................................................................................. 889
Section 137.2: Install all apk file in directory ........................................................................................................... 889
Section 137.3: Install an app ..................................................................................................................................... 889
Chapter 138: IntentService ................................................................................................................................... 890
Section 138.1: Creating an IntentService .................................................................................................................. 890
Section 138.2: Basic IntentService Example ............................................................................................................ 890
Section 138.3: Sample Intent Service ....................................................................................................................... 891
Chapter 139: AdMob ................................................................................................................................................. 893
Section 139.1: Implementing ...................................................................................................................................... 893
Chapter 140: Implicit Intents ............................................................................................................................... 895
Section 140.1: Implicit and Explicit Intents ............................................................................................................... 895
Section 140.2: Implicit Intents ................................................................................................................................... 895
Chapter 141: Publish to Play Store ................................................................................................................... 896
Section 141.1: Minimal app submission guide .......................................................................................................... 896
Chapter 142: Firebase Realtime DataBase ................................................................................................. 898
Section 142.1: Quick setup ......................................................................................................................................... 898
Section 142.2: Firebase Realtime DataBase event handler .................................................................................. 898
Section 142.3: Understanding firebase JSON database ....................................................................................... 899
Section 142.4: Retrieving data from firebase ......................................................................................................... 900
Section 142.5: Listening for child updates ............................................................................................................... 901
Section 142.6: Retrieving data with pagination ...................................................................................................... 902
Section 142.7: Denormalization: Flat Database Structure ..................................................................................... 903
Section 142.8: Designing and understanding how to retrieve realtime data from the Firebase Database
............................................................................................................................................................................. 905
Chapter 143: Image Compression .................................................................................................................... 908
Section 143.1: How to compress image without size change ................................................................................ 908
Chapter 144: Email Validation ........................................................................................................................... 911
Section 144.1: Email address validation ................................................................................................................... 911
Section 144.2: Email Address validation with using Patterns ................................................................................ 911
Chapter 145: Keyboard ......................................................................................................................................... 912
Section 145.1: Register a callback for keyboard open and close ......................................................................... 912
Section 145.2: Hide keyboard when user taps anywhere else on the screen ..................................................... 912
Chapter 146: Button ................................................................................................................................................ 914
Section 146.1: Using the same click event for one or more Views in the XML ..................................................... 914
Section 146.2: Defining external Listener ................................................................................................................ 914
Section 146.3: inline onClickListener ......................................................................................................................... 915
Section 146.4: Customizing Button style .................................................................................................................. 915
Section 146.5: Custom Click Listener to prevent multiple fast clicks .................................................................... 919
Section 146.6: Using the layout to define a click action ........................................................................................ 919
Section 146.7: Listening to the long click events ..................................................................................................... 920
Chapter 147: TextInputLayout ........................................................................................................................... 921
Section 147.1: Basic usage ......................................................................................................................................... 921
Section 147.2: Password Visibility Toggles .............................................................................................................. 921
Section 147.3: Adding Character Counting ............................................................................................................. 921
Section 147.4: Handling Errors ................................................................................................................................. 922
Section 147.5: Customizing the appearance of the TextInputLayout .................................................................. 922
Section 147.6: TextInputEditText .............................................................................................................................. 923
Chapter 148: Bottom Sheets ............................................................................................................................... 925
Section 148.1: Quick Setup ........................................................................................................................................ 925
Section 148.2: BottomSheetBehavior like Google maps ....................................................................................... 925
Section 148.3: Modal bottom sheets with BottomSheetDialog ............................................................................. 932
Section 148.4: Modal bottom sheets with BottomSheetDialogFragment ............................................................ 932
Section 148.5: Persistent Bottom Sheets ................................................................................................................. 932
Section 148.6: Open BottomSheet DialogFragment in Expanded mode by default .......................................... 933
Chapter 149: CoordinatorLayout and Behaviors ..................................................................................... 935
Section 149.1: Creating a simple Behavior .............................................................................................................. 935
Section 149.2: Using the SwipeDismissBehavior ..................................................................................................... 936
Section 149.3: Create dependencies between Views ............................................................................................. 936
Chapter 150: EditText ............................................................................................................................................. 938
Section 150.1: Working with EditTexts ...................................................................................................................... 938
Section 150.2: Customizing the InputType .............................................................................................................. 940
Section 150.3: Icon or button inside Custom Edit Text and its action and click listeners ................................... 940
Section 150.4: Hiding SoftKeyboard ........................................................................................................................ 942
Section 150.5: `inputype` attribute ............................................................................................................................ 943
Chapter 151: Android PayPal Gateway Integration ................................................................................. 945
Section 151.1: Setup PayPal in your android code .................................................................................................. 945
Chapter 152: Firebase App Indexing ................................................................................................................ 947
Section 152.1: Supporting Http URLs ........................................................................................................................ 947
Section 152.2: Add AppIndexing API ........................................................................................................................ 948
Chapter 153: Firebase Crash Reporting ........................................................................................................ 950
Section 153.1: How to report an error ...................................................................................................................... 950
Section 153.2: How to add Firebase Crash Reporting to your app ...................................................................... 950
Chapter 154: Displaying Google Ads .............................................................................................................. 952
Section 154.1: Adding Interstitial Ad ......................................................................................................................... 952
Section 154.2: Basic Ad Setup ................................................................................................................................... 953
Chapter 155: Android Vk Sdk .............................................................................................................................. 955
Section 155.1: Initialization and login ........................................................................................................................ 955
Chapter 156: Localized Date/Time in Android ........................................................................................... 957
Section 156.1: Custom localized date format with DateUtils.formatDateTime() ................................................. 957
Section 156.2: Standard date/time formatting in Android .................................................................................... 957
Section 156.3: Fully customized date/time ............................................................................................................. 957
Chapter 157: Count Down Timer ....................................................................................................................... 958
Section 157.1: Creating a simple countdown timer ................................................................................................. 958
Section 157.2: A More Complex Example ................................................................................................................ 958
Chapter 158: Barcode and QR code reading .............................................................................................. 960
Section 158.1: Using QRCodeReaderView (based on Zxing) ................................................................................. 960
Chapter 159: Otto Event Bus ............................................................................................................................... 962
Section 159.1: Passing an event ................................................................................................................................ 962
Section 159.2: Receiving an event ............................................................................................................................ 962
Chapter 160: TransitionDrawable ..................................................................................................................... 964
Section 160.1: Animate views background color (switch-color) with TransitionDrawable ................................. 964
Section 160.2: Add transition or Cross-fade between two images ...................................................................... 964
Chapter 161: Port Mapping using Cling library in Android .................................................................... 966
Section 161.1: Mapping a NAT port ........................................................................................................................... 966
Section 161.2: Adding Cling Support to your Android Project ............................................................................... 966
Chapter 162: Creating Overlay (always-on-top) Windows .................................................................. 968
Section 162.1: Popup overlay .................................................................................................................................... 968
Section 162.2: Granting SYSTEM_ALERT_WINDOW Permission on android 6.0 and above ............................ 968
Chapter 163: ExoPlayer .......................................................................................................................................... 970
Section 163.1: Add ExoPlayer to the project ............................................................................................................ 970
Section 163.2: Using ExoPlayer ................................................................................................................................. 970
Section 163.3: Main steps to play video & audio using the standard TrackRenderer implementations
............................................................................................................................................................................. 971
Chapter 164: Inter-app UI testing with UIAutomator ............................................................................. 972
Section 164.1: Prepare your project and write the first UIAutomator test ........................................................... 972
Section 164.2: Writing more complex tests using the UIAutomatorViewer ......................................................... 972
Section 164.3: Creating a test suite of UIAutomator tests ..................................................................................... 974
Chapter 165: MediaSession .................................................................................................................................. 975
Section 165.1: Receiving and handling button events ............................................................................................ 975
Chapter 166: Speech to Text Conversion ...................................................................................................... 978
Section 166.1: Speech to Text With Default Google Prompt Dialog ...................................................................... 978
Section 166.2: Speech to Text without Dialog ......................................................................................................... 979
Chapter 167: FileProvider ...................................................................................................................................... 981
Section 167.1: Sharing a file ....................................................................................................................................... 981
Chapter 168: XMPP register login and chat simple example .............................................................. 983
Section 168.1: XMPP register login and chat basic example ................................................................................. 983
Chapter 169: Android Authenticator ............................................................................................................... 992
Section 169.1: Basic Account Authenticator Service ............................................................................................... 992
Chapter 170: RecyclerView and LayoutManagers ................................................................................... 995
Section 170.1: Adding header view to recyclerview with gridlayout manager .................................................... 995
Section 170.2: GridLayoutManager with dynamic span count ............................................................................. 996
Section 170.3: Simple list with LinearLayoutManager ............................................................................................ 998
Section 170.4: StaggeredGridLayoutManager ..................................................................................................... 1002
Chapter 171: AudioManager ............................................................................................................................... 1005
Section 171.1: Requesting Transient Audio Focus ................................................................................................. 1005
Section 171.2: Requesting Audio Focus .................................................................................................................. 1005
Chapter 172: Job Scheduling ............................................................................................................................. 1006
Section 172.1: Basic usage ...................................................................................................................................... 1006
Chapter 173: Accounts and AccountManager .......................................................................................... 1008
Section 173.1: Understanding custom accounts/authentication ........................................................................ 1008
Chapter 174: Integrate OpenCV into Android Studio ........................................................................... 1010
Section 174.1: Instructions ....................................................................................................................................... 1010
Chapter 175: Split Screen / Multi-Screen Activities ............................................................................... 1018
Section 175.1: Split Screen introduced in Android Nougat implemented ........................................................... 1018
Chapter 176: Thread .............................................................................................................................................. 1019
Section 176.1: Thread Example with its description .............................................................................................. 1019
Section 176.2: Updating the UI from a Background Thread ............................................................................... 1019
Chapter 177: MediaStore .................................................................................................................................... 1021
Section 177.1: Fetch Audio/MP3 files from specific folder of device or fetch all files ....................................... 1021
Chapter 178: Time Utils ........................................................................................................................................ 1024
Section 178.1: To check within a period ................................................................................................................. 1024
Section 178.2: Convert Date Format into Milliseconds ........................................................................................ 1024
Section 178.3: GetCurrentRealTime ....................................................................................................................... 1025
Chapter 179: Touch Events ................................................................................................................................ 1026
Section 179.1: How to vary between child and parent view group touch events .............................................. 1026
Chapter 180: Fingerprint API in android ...................................................................................................... 1029
Section 180.1: How to use Android Fingerprint API to save user passwords ..................................................... 1029
Section 180.2: Adding the Fingerprint Scanner in Android application ............................................................. 1036
Chapter 181: MVVM (Architecture) ................................................................................................................. 1039
Section 181.1: MVVM Example using DataBinding Library ................................................................................... 1039
Chapter 182: BottomNavigationView ........................................................................................................... 1046
Section 182.1: Basic implemetation ........................................................................................................................ 1046
Section 182.2: Customization of BottomNavigationView .................................................................................... 1047
Section 182.3: Handling Enabled / Disabled states ............................................................................................. 1047
Section 182.4: Allowing more than 3 menus ......................................................................................................... 1048
Chapter 183: ORMLite in android .................................................................................................................... 1050
Section 183.1: Android OrmLite over SQLite example .......................................................................................... 1050
Chapter 184: Youtube-API .................................................................................................................................. 1054
Section 184.1: Activity extending YouTubeBaseActivity ....................................................................................... 1054
Section 184.2: Consuming YouTube Data API on Android .................................................................................. 1055
Section 184.3: Launching StandAlonePlayerActivity ............................................................................................ 1057
Section 184.4: YoutubePlayerFragment in portrait Activty ................................................................................. 1058
Section 184.5: YouTube Player API ........................................................................................................................ 1060
Chapter 185: TabLayout ..................................................................................................................................... 1063
Section 185.1: Using a TabLayout without a ViewPager ...................................................................................... 1063
Chapter 186: Retrofit2 with RxJava .............................................................................................................. 1064
Section 186.1: Retrofit2 with RxJava ...................................................................................................................... 1064
Section 186.2: Nested requests example: multiple requests, combine results .................................................. 1065
Section 186.3: Retrofit with RxJava to fetch data asyncronously ...................................................................... 1066
Chapter 187: DayNight Theme (AppCompat v23.2 / API 14+) .......................................................... 1069
Section 187.1: Adding the DayNight theme to an app ......................................................................................... 1069
Chapter 188: ShortcutManager ....................................................................................................................... 1070
Section 188.1: Dynamic Launcher Shortcuts ......................................................................................................... 1070
Chapter 189: LruCache ......................................................................................................................................... 1071
Section 189.1: Adding a Bitmap(Resource) to the cache ..................................................................................... 1071
Section 189.2: Initialising the cache ....................................................................................................................... 1071
Section 189.3: Getting a Bitmap(Resouce) from the cache ................................................................................ 1071
Chapter 190: Jenkins CI setup for Android Projects ............................................................................. 1072
Section 190.1: Step by step approach to set up Jenkins for Android ................................................................. 1072
Chapter 191: Zip file in android ........................................................................................................................ 1076
Section 191.1: Zip file on android ............................................................................................................................ 1076
Chapter 192: Vector Drawables ....................................................................................................................... 1077
Section 192.1: Importing SVG file as VectorDrawable ......................................................................................... 1077
Section 192.2: VectorDrawable Usage Example .................................................................................................. 1079
Section 192.3: VectorDrawable xml example ....................................................................................................... 1080
Chapter 193: fastlane ............................................................................................................................................ 1081
Section 193.1: Fastfile lane to build and install all flavors for given build type to a device ............................. 1081
Section 193.2: Fastfile to build and upload multiple flavors to Beta by Crashlytics ......................................... 1081
Chapter 194: Define step value (increment) for custom RangeSeekBar .................................. 1084
Section 194.1: Define a step value of 7 .................................................................................................................. 1084
Chapter 195: Getting started with OpenGL ES 2.0+ .............................................................................. 1085
Section 195.1: Setting up GLSurfaceView and OpenGL ES 2.0+ .......................................................................... 1085
Section 195.2: Compiling and Linking GLSL-ES Shaders from asset file ........................................................... 1085
Chapter 196: Check Data Connection ........................................................................................................... 1088
Section 196.1: Check data connection ................................................................................................................... 1088
Section 196.2: Check connection using ConnectivityManager ........................................................................... 1088
Section 196.3: Use network intents to perform tasks while data is allowed ..................................................... 1088
Chapter 197: Android Java Native Interface (JNI) ................................................................................ 1089
Section 197.1: How to call functions in a native library via the JNI interface .................................................... 1089
Section 197.2: How to call a Java method from native code ............................................................................. 1089
Section 197.3: Utility method in JNI layer .............................................................................................................. 1090
Chapter 198: FileIO with Android ..................................................................................................................... 1092
Section 198.1: Obtaining the working folder ......................................................................................................... 1092
Section 198.2: Writing raw array of bytes ............................................................................................................ 1092
Section 198.3: Serializing the object ....................................................................................................................... 1092
Section 198.4: Writing to external storage (SD card) .......................................................................................... 1093
Section 198.5: Solving "Invisible MTP files" problem ............................................................................................ 1093
Section 198.6: Working with big files ..................................................................................................................... 1093
Chapter 199: Performance Optimization .................................................................................................... 1095
Section 199.1: Save View lookups with the ViewHolder pattern .......................................................................... 1095
Chapter 200: Robolectric ................................................................................................................................... 1096
Section 200.1: Robolectric test ............................................................................................................................... 1096
Section 200.2: Configuration ................................................................................................................................. 1096
Chapter 201: Moshi ................................................................................................................................................. 1098
Section 201.1: JSON into Java ................................................................................................................................ 1098
Section 201.2: serialize Java objects as JSON ..................................................................................................... 1098
Section 201.3: Built in Type Adapters .................................................................................................................... 1098
Chapter 202: Strict Mode Policy : A tool to catch the bug in the Compile Time. ................... 1100
Section 202.1: The below Code Snippet is to setup the StrictMode for Thread Policies. This Code is to be set
at the entry points to our application ........................................................................................................... 1100
Section 202.2: The below code deals with leaks of memory, like it detects when in SQLLite finalize is called
or not ................................................................................................................................................................ 1100
Chapter 203: Internationalization and localization (I18N and L10N) ............................................ 1101
Section 203.1: Planning for localization : enable RTL support in Manifest ........................................................ 1101
Section 203.2: Planning for localization : Add RTL support in Layouts ............................................................. 1101
Section 203.3: Planning for localization : Test layouts for RTL .......................................................................... 1102
Section 203.4: Coding for Localization : Creating default strings and resources ............................................ 1102
Section 203.5: Coding for localization : Providing alternative strings ............................................................... 1103
Section 203.6: Coding for localization : Providing alternate layouts ................................................................. 1104
Chapter 204: Fast way to setup Retrolambda on an android project. ..................................... 1105
Section 204.1: Setup and example how to use: .................................................................................................... 1105
Chapter 205: How to use SparseArray ........................................................................................................ 1107
Section 205.1: Basic example using SparseArray ................................................................................................ 1107
Chapter 206: Firebase Cloud Messaging .................................................................................................... 1109
Section 206.1: Set Up a Firebase Cloud Messaging Client App on Android ...................................................... 1109
Section 206.2: Receive Messages .......................................................................................................................... 1109
Section 206.3: This code that i have implemnted in my app for pushing image,message and also link for
opening in your webView ............................................................................................................................... 1110
Section 206.4: Registration token ......................................................................................................................... 1111
Section 206.5: Subscribe to a topic ....................................................................................................................... 1112
Chapter 207: Shared Element Transitions ................................................................................................ 1113
Section 207.1: Shared Element Transition between two Fragments ................................................................. 1113
Chapter 208: Android Things ............................................................................................................................ 1116
Section 208.1: Controlling a Servo Motor .............................................................................................................. 1116
Chapter 209: VideoView ...................................................................................................................................... 1118
Section 209.1: Play video from URL with using VideoView ................................................................................. 1118
Section 209.2: VideoView Create .......................................................................................................................... 1118
Chapter 210: ViewFlipper .................................................................................................................................... 1119
Section 210.1: ViewFlipper with image sliding ....................................................................................................... 1119
Chapter 211: Library Dagger 2: Dependency Injection in Applications ....................................... 1120
Section 211.1: Create @Module Class and @Singleton annotation for Object .................................................. 1120
Section 211.2: Request Dependencies in Dependent Objects ............................................................................. 1120
Section 211.3: Connecting @Modules with @Inject .............................................................................................. 1120
Section 211.4: Using @Component Interface to Obtain Objects ........................................................................ 1121
Chapter 212: Formatting phone numbers with pattern. ..................................................................... 1122
Section 212.1: Patterns + 1 (786) 1234 5678 ........................................................................................................... 1122
Chapter 213: How to store passwords securely ...................................................................................... 1123
Section 213.1: Using AES for salted password encryption ................................................................................... 1123
Chapter 214: Android Kernel Optimization ................................................................................................ 1126
Section 214.1: Low RAM Configuration .................................................................................................................. 1126
Section 214.2: How to add a CPU Governor ......................................................................................................... 1126
Section 214.3: I/O Schedulers ................................................................................................................................. 1128
Chapter 215: Paint .................................................................................................................................................. 1129
Section 215.1: Creating a Paint ............................................................................................................................... 1129
Section 215.2: Setting up Paint for text ................................................................................................................. 1129
Section 215.3: Setting up Paint for drawing shapes ............................................................................................. 1130
Section 215.4: Setting flags ..................................................................................................................................... 1130
Chapter 216: AudioTrack ..................................................................................................................................... 1131
Section 216.1: Generate tone of a specific frequency .......................................................................................... 1131
Chapter 217: What is ProGuard? What is use in Android? ................................................................. 1132
Section 217.1: Shrink your code and resources with proguard ........................................................................... 1132
Chapter 218: Create Android Custom ROMs ............................................................................................. 1134
Section 218.1: Making Your Machine Ready for Building! .................................................................................... 1134
Chapter 219: Java on Android .......................................................................................................................... 1135
Section 219.1: Java 8 features subset with Retrolambda ................................................................................... 1135
Chapter 220: Pagination in RecyclerView .................................................................................................. 1137
Section 220.1: MainActivity.java ............................................................................................................................. 1137
Chapter 221: Genymotion for android ......................................................................................................... 1142
Section 221.1: Installing Genymotion, the free version ......................................................................................... 1142
Section 221.2: Google framework on Genymotion .............................................................................................. 1143
Chapter 222: Handling touch and motion events .................................................................................. 1144
Section 222.1: Buttons ............................................................................................................................................. 1144
Section 222.2: Surface ............................................................................................................................................ 1145
Section 222.3: Handling multitouch in a surface ................................................................................................. 1146
Chapter 223: Creating Splash screen ........................................................................................................... 1147
Section 223.1: Splash screen with animation ........................................................................................................ 1147
Section 223.2: A basic splash screen .................................................................................................................... 1148
Chapter 224: ConstraintSet .............................................................................................................................. 1151
Section 224.1: ConstraintSet with ContraintLayout Programmatically ............................................................. 1151
Chapter 225: CleverTap ...................................................................................................................................... 1152
Section 225.1: Setting the debug level ................................................................................................................... 1152
Section 225.2: Get an instance of the SDK to record events ............................................................................. 1152
Chapter 226: Publish a library to Maven Repositories ........................................................................ 1153
Section 226.1: Publish .aar file to Maven ............................................................................................................... 1153
Chapter 227: adb shell ......................................................................................................................................... 1155
Section 227.1: Granting & revoking API 23+ permissions .................................................................................... 1155
Section 227.2: Send text, key pressed and touch events to Android Device via ADB ..................................... 1155
Section 227.3: List packages .................................................................................................................................. 1157
Section 227.4: Recording the display .................................................................................................................... 1157
Section 227.5: Open Developer Options ............................................................................................................... 1158
Section 227.6: Set Date/Time via adb .................................................................................................................. 1158
Section 227.7: Generating a "Boot Complete" broadcast .................................................................................. 1159
Section 227.8: Print application data .................................................................................................................... 1159
Section 227.9: Changing file permissions using chmod command ................................................................... 1159
Section 227.10: View external/secondary storage content ................................................................................ 1160
Section 227.11: kill a process inside an Android device ....................................................................................... 1160
Chapter 228: Ping ICMP ....................................................................................................................................... 1162
Section 228.1: Performs a single Ping ................................................................................................................... 1162
Chapter 229: AIDL ................................................................................................................................................... 1163
Section 229.1: AIDL Service ..................................................................................................................................... 1163
Chapter 230: Android programming with Kotlin .................................................................................... 1165
Section 230.1: Installing the Kotlin plugin .............................................................................................................. 1165
Section 230.2: Configuring an existing Gradle project with Kotlin ..................................................................... 1166
Section 230.3: Creating a new Kotlin Activity ....................................................................................................... 1167
Section 230.4: Converting existing Java code to Kotlin ...................................................................................... 1168
Section 230.5: Starting a new Activity ................................................................................................................... 1168
Chapter 231: Autosizing TextViews ................................................................................................................ 1169
Section 231.1: Granularity ........................................................................................................................................ 1169
Section 231.2: Preset Sizes ...................................................................................................................................... 1169
Chapter 232: Sign your Android App for Release .................................................................................. 1171
Section 232.1: Sign your App .................................................................................................................................. 1171
Section 232.2: Configure the build.gradle with signing configuration ............................................................... 1172
Chapter 233: Activity Recognition .................................................................................................................. 1174
Section 233.1: Google Play ActivityRecognitionAPI .............................................................................................. 1174
Section 233.2: PathSense Activity Recognition .................................................................................................... 1176
Chapter 234: Secure SharedPreferences .................................................................................................. 1178
Section 234.1: Securing a Shared Preference ....................................................................................................... 1178
Chapter 235: Secure SharedPreferences ................................................................................................... 1179
Section 235.1: Securing a Shared Preference ....................................................................................................... 1179
Chapter 236: Bitmap Cache ............................................................................................................................... 1180
Section 236.1: Bitmap Cache Using LRU Cache ................................................................................................... 1180
Chapter 237: Android-x86 in VirtualBox ...................................................................................................... 1181
Section 237.1: Virtual hard drive Setup for SDCARD Support ............................................................................. 1181
Section 237.2: Installation in partition ................................................................................................................... 1183
Section 237.3: Virtual Machine setup .................................................................................................................... 1185
Chapter 238: JCodec ............................................................................................................................................. 1186
Section 238.1: Getting Started ................................................................................................................................ 1186
Section 238.2: Getting frame from movie ............................................................................................................ 1186
Chapter 239: Design Patterns .......................................................................................................................... 1187
Section 239.1: Observer pattern ............................................................................................................................. 1187
Section 239.2: Singleton Class Example ............................................................................................................... 1187
Chapter 240: Okio .................................................................................................................................................. 1189
Section 240.1: Download / Implement .................................................................................................................. 1189
Section 240.2: PNG decoder .................................................................................................................................. 1189
Section 240.3: ByteStrings and Buers ................................................................................................................ 1189
Chapter 241: Google signin integration on android ............................................................................. 1191
Section 241.1: Integration of google Auth in your project. (Get a configuration file) ....................................... 1191
Section 241.2: Code Implementation Google SignIn ............................................................................................ 1191
Chapter 242: TensorFlow ................................................................................................................................... 1193
Section 242.1: How to use ....................................................................................................................................... 1193
Chapter 243: Android game development ............................................................................................... 1194
Section 243.1: Game using Canvas and SurfaceView ......................................................................................... 1194
Chapter 244: Notification Channel Android O ........................................................................................ 1200
Section 244.1: Notification Channel ....................................................................................................................... 1200
Chapter 245: Bluetooth Low Energy ............................................................................................................ 1206
Section 245.1: Finding BLE Devices ........................................................................................................................ 1206
Section 245.2: Connecting to a GATT Server ....................................................................................................... 1206
Section 245.3: Writing and Reading from Characteristics .................................................................................. 1207
Section 245.4: Subscribing to Notifications from the Gatt Server ...................................................................... 1208
Section 245.5: Advertising a BLE Device ............................................................................................................... 1208
Section 245.6: Using a Gatt Server ........................................................................................................................ 1209
Chapter 246: Leakcanary .................................................................................................................................. 1211
Section 246.1: Implementing a Leak Canary in Android Application ................................................................. 1211
Chapter 247: Adding a FuseView to an Android Project .................................................................... 1212
Section 247.1: hikr app, just another android.view.View ...................................................................................... 1212
Chapter 248: Accessing SQLite databases using the ContentValues class ............................. 1219
Section 248.1: Inserting and updating rows in a SQLite database ..................................................................... 1219
Chapter 249: Enhancing Alert Dialogs ........................................................................................................ 1220
Section 249.1: Alert dialog containing a clickable link ......................................................................................... 1220
Chapter 250: Hardware Button Events/Intents (PTT, LWP, etc.) .................................................. 1221
Section 250.1: Sonim Devices ................................................................................................................................. 1221
Section 250.2: RugGear Devices ........................................................................................................................... 1221
Chapter 251: SpannableString ......................................................................................................................... 1222
Section 251.1: Add styles to a TextView ................................................................................................................. 1222
Section 251.2: Multi string , with multi color .......................................................................................................... 1224
Chapter 252: Looper ............................................................................................................................................. 1226
Section 252.1: Create a simple LooperThread ..................................................................................................... 1226
Section 252.2: Run a loop with a HandlerThread ................................................................................................ 1226
Chapter 253: Optimized VideoView ............................................................................................................... 1227
Section 253.1: Optimized VideoView in ListView ................................................................................................... 1227
Chapter 254: Google Drive API ........................................................................................................................ 1239
Section 254.1: Integrate Google Drive in Android ................................................................................................ 1239
Section 254.2: Create a File on Google Drive ....................................................................................................... 1247
Chapter 255: Animated AlertDialog Box ..................................................................................................... 1250
Section 255.1: Put Below code for Animated dialog.. ........................................................................................... 1250
Chapter 256: Annotation Processor .............................................................................................................. 1253
Section 256.1: @NonNull Annotation ..................................................................................................................... 1253
Section 256.2: Types of Annotations .................................................................................................................... 1253
Section 256.3: Creating and Using Custom Annotations .................................................................................... 1253
Chapter 257: SyncAdapter with periodically do sync of data ........................................................ 1255
Section 257.1: Sync adapter with every min requesting value from server ...................................................... 1255
Chapter 258: Create Singleton Class for Toast Message .................................................................. 1265
Section 258.1: Create own singleton class for toast massages ......................................................................... 1265
Chapter 259: Fastjson .......................................................................................................................................... 1267
Section 259.1: Parsing JSON with Fastjson ........................................................................................................... 1267
Section 259.2: Convert the data of type Map to JSON String ........................................................................... 1268
Chapter 260: Android Architecture Components ................................................................................... 1270
Section 260.1: Using Lifecycle in AppCompatActivity .......................................................................................... 1270
Section 260.2: Add Architecture Components ..................................................................................................... 1270
Section 260.3: ViewModel with LiveData transformations ................................................................................. 1271
Section 260.4: Room peristence ............................................................................................................................ 1272
Section 260.5: Custom LiveData ............................................................................................................................ 1274
Section 260.6: Custom Lifecycle-aware component ........................................................................................... 1274
Chapter 261: Jackson ............................................................................................................................................ 1276
Section 261.1: Full Data Binding Example .............................................................................................................. 1276
Chapter 262: Google Play Store ...................................................................................................................... 1278
Section 262.1: Open Google Play Store Listing for your app .............................................................................. 1278
Section 262.2: Open Google Play Store with the list of all applications from your publisher account .......... 1278
Chapter 263: Loading Bitmaps Eectively ................................................................................................ 1280
Section 263.1: Load the Image from Resource from Android Device. Using Intents ....................................... 1280
Chapter 264: Getting system font names and using the fonts ...................................................... 1285
Section 264.1: Getting system font names ........................................................................................................... 1285
Section 264.2: Applying a system font to a TextView ......................................................................................... 1285
Chapter 265: Smartcard ..................................................................................................................................... 1286
Section 265.1: Smart card send and receive ........................................................................................................ 1286
Chapter 266: Convert vietnamese string to english string Android ............................................. 1288
Section 266.1: example: ........................................................................................................................................... 1288
Section 266.2: Chuyển chuỗi Tiếng Việt thành chuỗi không dấu ....................................................................... 1288
Credits .......................................................................................................................................................................... 1289
You may also like ................................................................................................................................................... 1301
About
Please feel free to share this PDF with anyone for free,
latest version of this book can be downloaded from:
https://goalkicker.com/AndroidBook
This Android™ Notes for Professionals book is compiled from Stack Overflow
Documentation, the content is written by the beautiful people at Stack Overflow.
Text content is released under Creative Commons BY-SA, see credits at the end
of this book whom contributed to the various chapters. Images may be copyright
of their respective owners unless otherwise specified
This is an unofficial free book created for educational purposes and is not
affiliated with official Android™ group(s) or company(s) nor Stack Overflow. All
trademarks and registered trademarks are the property of their respective
company owners
Start by setting up Android Studio and then open it. Now, you're ready to make your first Android App!
Note: this guide is based on Android Studio 2.2, but the process on other versions is mainly the same.
Click Start a New Android Studio Project from the welcome screen.
Navigate to File → New Project if you already have a project open.
Next, you need to describe your application by filling out some fields:
Example: Hello World. You can always change it later in AndroidManifest.xml file.
2. Company Domain - This is the qualifier for your project's package name.
Example: stackoverflow.com.
3. Package Name (aka applicationId) - This is the fully qualified project package name.
It should follow Reverse Domain Name Notation (aka Reverse DNS): Top Level Domain . Company Domain .
[Company Segment .] Application Name.
Don't use the default prefix "com.example" unless you don't intend to submit your application to the
Google Play Store. The package name will be your unique applicationId in Google Play.
4. Project Location - This is the directory where your project will be stored.
The next window lets you select the form factors supported by your app, such as phone, tablet, TV, Wear, and
Google Glass. The selected form factors become the app modules within the project. For each form factor, you can
also select the API Level for that app. To get more information, click Help me choose
The Android Platform Distribution window shows the distribution of mobile devices running each version of
Android, as shown in Figure 2. Click on an API level to see a list of features introduced in the corresponding version
of Android. This helps you choose the minimum API Level that has all the features that your apps needs, so you can
reach as many devices as possible. Then click OK.
Now, choose what platforms and version of Android SDK the application will support.
The Minimum SDK is the lower bound for your app. It is one of the signals the Google Play Store uses to
determine which devices an app can be installed on. For example, Stack Exchange's app supports Android 4.1+.
Android Studio will tell you (approximately) what percentage of devices will be supported given the specified
minimum SDK.
When deciding on the Minimum SDK, you should consider the Dashboards stats, which will give you version
information about the devices that visited the Google Play Store globally in the last week.
Add an activity
Now we are going to select a default activity for our application. In Android, an Activity is a single screen that will
be presented to the user. An application can house multiple activities and navigate between them. For this
example, choose Empty Activity and click next.
Here, if you wish, you can change the name of the activity and layout. A good practice is to keep Activity as a suffix
for the activity name, and activity_ as a prefix for the layout name. If we leave these as the default, Android
Studio will generate an activity for us called MainActivity, and a layout file called activity_main. Now click Finish.
Android Studio will create and configure our project, which can take some time depending on the system.
To understand how Android works, let's take a look at some of the files that were created for us.
On the left pane of Android Studio, we can see the structure of our Android application.
If an application needs access to a feature protected by a permission, it must declare that it requires that
permission with a <uses-permission> element in the manifest. Then, when the application is installed on the
device, the installer determines whether or not to grant the requested permission by checking the authorities that
signed the application's certificates and, in some cases, asking the user. An application can also protect its own
components (activities, services, broadcast receivers, and content providers) with permissions. It can employ any of
the permissions defined by Android (listed in android.Manifest.permission) or declared by other applications. Or it
can define its own.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Next, let's open activity_main.xml which is located in app/src/main/res/layout/. This file contains declarations
for the visual components of our MainActivity. You will see visual designer. This allows you to drag and drop
elements onto the selected layout.
You can also switch to the xml layout designer by clicking "Text" at the bottom of Android Studio, as seen here:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
You will see a widget called a TextView inside of this layout, with the android:text property set to "Hello World!".
This is a block of text that will be shown to the user when they run the application.
Next, let's take a look at MainActivity. This is the Java code that has been generated for MainActivity.
As defined in our Android manifest, MainActivity will launch by default when a user starts the HelloWorld app.
android {
signingConfigs {
applicationName {
keyAlias 'applicationName'
keyPassword 'password'
storeFile file('../key/applicationName.jks')
storePassword 'anotherPassword'
}
}
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.stackexchange.docs.helloworld"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
signingConfig signingConfigs.applicationName
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0'
}
This file contains information about the build and your app version, and you can also use it to add dependencies to
external libraries. For now, let's not make any changes.
It is advisable to always select the latest version available for the dependencies:
buildToolsVersion: 26.0.0
com.android.support:appcompat-v7: 26.0.0 (July 2017)
firebase: 11.0.4 (August 2017)
compileSdkVersion is your way to tell Gradle what version of the Android SDK to compile your app with. Using the
new Android SDK is a requirement to use any of the new APIs added in that level.
It should be emphasized that changing your compileSdkVersion does not change runtime behavior. While new
compiler warnings/errors may be present when changing your compileSdkVersion, your compileSdkVersion is not
included in your APK: it is purely used at compile time.
Therefore it is strongly recommended that you always compile with the latest SDK. You’ll get all the benefits of new
compilation checks on existing code, avoid newly deprecated APIs, and be ready to use new APIs.
minSdkVersion
If compileSdkVersion sets the newest APIs available to you, minSdkVersion is the lower bound for your app. The
minSdkVersion is one of the signals the Google Play Store uses to determine which of a user’s devices an app can
be installed on.
It also plays an important role during development: by default lint runs against your project, warning you when you
use any APIs above your minSdkVersion, helping you avoid the runtime issue of attempting to call an API that
doesn’t exist. Checking the system version at runtime is a common technique when using APIs only on newer
platform versions.
targetSdkVersion
targetSdkVersion is the main way Android provides forward compatibility by not applying behavior changes unless
the targetSdkVersion is updated. This allows you to use new APIs prior to working through the behavior changes.
Updating to target the latest SDK should be a high priority for every app. That doesn’t mean you have to use every
new feature introduced nor should you blindly update your targetSdkVersion without testing.
targetSDKVersion is the version of Android which is the upper-limit for the available tools. If targetSDKVersion is
less than 23, the app does not need to request permissions at runtime for an instance, even if the app is being run
on API 23+. TargetSDKVersion does not prevent android versions above the picked Android version from running
the app.
A basic example
Introduction to the Gradle plugin for android and the wrapper
Introduction to the configuration of the build.gradle and the DSL methods
Now, let's run our HelloWorld application. You can either run an Android Virtual Device (which you can set up by
using the AVD Manager in Android Studio, as described in the example below) or connect your own Android device
through a USB cable.
To run an application from Android Studio on your Android Device, you must enable USB Debugging in the
Developer Options in the settings of your device.
If Developer Options is not visible in the settings, navigate to About Phone and tap on the Build Number seven
You also might need to change build.gradle configuration to build on a version that your device has.
Click the green Run button from the toolbar at the top of Android Studio. In the window that appears, select
whichever device you would like to run the app on (start an Android Virtual Device if necessary, or see Setting up an
AVD (Android Virtual Device) if you need to set one up) and click OK.
On devices running Android 4.4 (KitKat) and possibly higher, a pop-up will be shown to authorize USB debugging.
Click OK to accept.
The application will now install and run on your Android device or emulator.
When you prepare your application for release, you configure, build, and test a release version of your application.
The configuration tasks are straightforward, involving basic code cleanup and code modification tasks that help
optimize your application. The build process is similar to the debug build process and can be done using JDK and
Android SDK tools. The testing tasks serve as a final check, ensuring that your application performs as expected
under real-world conditions. When you are finished preparing your application for release you have a signed APK
file, which you can distribute directly to users or distribute through an application marketplace such as Google Play.
Android Studio
Since in the above examples Gradle is used, the location of the generated APK file is: <Your Project
Location>/app/build/outputs/apk/app-debug.apk
IntelliJ
If you are a user of IntelliJ before switching to Studio, and are importing your IntelliJ project directly, then nothing
changed. The location of the output will be the same under:
out/production/...
Eclipse
If you are importing Android Eclipse project directly, do not do this! As soon as you have dependencies in your
project (jars or Library Projects), this will not work and your project will not be properly setup. If you have no
dependencies, then the apk would be under the same location as you'd find it in Eclipse:
bin/...
If you need to work on old projects that were built using older SDK versions, you may need to download these
versions as well
Since Android Studio 2.2, a copy of the latest OpenJDK comes bundled with the install and is the recommended JDK
(Java Development Kit) for all Android Studio projects. This removes the requirement of having Oracle's JDK package
installed. To use the bundled SDK, proceed as follows;
1. Open your project in Android Studio and select File > Project Structure in the menu bar.
2. In the SDK Location page and under JDK location, check the Use embedded JDK checkbox.
3. Click OK.
Android Studio provides access to two configuration files through the Help menu:
studio.vmoptions: Customize options for Studio's Java Virtual Machine (JVM), such as heap size and cache
size. Note that on Linux machines this file may be named studio64.vmoptions, depending on your version of
Android Studio.
idea.properties: Customize Android Studio properties, such as the plugins folder path or maximum
supported file size.
Change/add theme
You can change it as your preference.File->Settings->Editor->Colors & Fonts-> and select a theme.Also you
can download new themes from http://color-themes.com/ Once you have downloaded the .jar.zip file, go to File
-> Import Settings... and choose the file downloaded.
Compiling Apps
Create a new project or open an existing project in Android Studio and press the green Play button on the top
toolbar to run it. If it is gray you need to wait a second to allow Android Studio to properly index some files, the
progress of which can be seen in the bottom status bar.
If you want to create a project from the shell make sure that you have a local.properties file, which is created by
Android Studio automatically. If you need to create the project without Android Studio you need a line starting with
sdk.dir= followed by the path to your SDK installation.
Open a shell and go into the project's directory. Enter ./gradlew aR and press enter. aR is a shortcut for
assembleRelease, which will download all dependencies for you and build the app. The final APK file will be in
ProjectName/ModuleName/build/outputs/apk and will been called ModuleName-release.apk.
This example assumes Linux. You may have to adjust the syntax for your own platform.
1. Install additional packages using the SDK manager. Don't use android update sdk --no-ui as instructed in
the bundled Readme.txt; it downloads some 30 GB of unnecessary files. Instead use the interactive SDK
manager android sdk to get the recommended minimum of packages.
2. Append the following JDK and SDK directories to your execution PATH. This is optional, but the instructions
below assume it.
JDK/bin
SDK/platform-tools
SDK/tools
SDK/build-tools/LATEST (as installed in step 1)
3. Create an Android virtual device. Use the interactive AVD Manager (android avd). You might have to fiddle a
bit and search for advice; the on-site instructions aren't always helpful.
Content:
package dom.domain;
import android.widget.TextView;
2. Add a manifest:
touch AndroidManifest.xml
Content:
<?xml version='1.0'?>
<manifest xmlns:a='http://schemas.android.com/apk/res/android'
package='dom.domain' a:versionCode='0' a:versionName='0'>
<application a:label='Saying hello'>
<activity a:name='dom.domain.SayingHello'>
<intent-filter>
<category a:name='android.intent.category.LAUNCHER'/>
<action a:name='android.intent.action.MAIN'/>
</intent-filter>
</activity>
</application>
</manifest>
mkdir res
0. Generate the source for the resource declarations. Substitute here the correct path to your SDK, and the
installed API to build against (e.g. "android-23"):
aapt package -f \\
-I SDK/platforms/android-API/android.jar \\
-J src -m \\
-M AndroidManifest.xml -S res -v
Resource declarations (described further below) are actually optional. Meantime the above call does nothing
if res/ is still empty.
javac \\
-bootclasspath SDK/platforms/android-API/android.jar \\
-classpath src -source 1.7 -target 1.7 \\
src/dom/domain/*.java
You could replace steps 11 and 12 with a single call to Jack if you like; it can compile directly from Java source
(.java → .dex). But there are advantages to compiling with javac. It's a better known, better documented and
more widely applicable tool.
aapt package -f \\
-F app.apkPart \\
-I SDK/platforms/android-API/android.jar \\
-M AndroidManifest.xml -S res -v
It warns, "THIS TOOL IS DEPRECATED. See --help for more information." If --help fails with an
ArrayIndexOutOfBoundsException, then instead pass no arguments:
It explains that the CLI (ApkBuilderMain) is deprecated in favour of directly calling the Java API (ApkBuilder).
(If you know how to do that from the command line, please update this example.)
That's all. That's what it takes to say hello using the basic Android tools.
Declaring a resource
This section is optional. Resource declarations aren't required for a simple "hello world" app. If they aren't required
for your app either, then you could streamline the build somewhat by omitting step 10, and removing the reference
to the res/ directory from step 13.
Otherwise, here's a brief example of how to declare a resource, and how to reference it.
mkdir res/values
touch res/values/values.xml
Content:
<?xml version='1.0'?>
<resources>
<string name='appLabel'>Saying hello</string>
</resources>
1. Reference the resource from the XML manifest. This is a declarative style of reference:
2. Reference the same resource from the Java source. This is an imperative reference:
3. Test the above modifications by rebuilding, reinstalling and re-running the app (steps 10-17).
See also
Each app runs on its own virtual machine(VM) so that app can run isolated from other apps. Android system works
with the principle of least privilege. Each app only has access to the components which it requires to do its work,
and no more. However, there are ways for an app to share data with other apps, such as by sharing Linux user id
between app, or apps can request permission to access device data like SD card, contacts etc.
App Components
App components are the building blocks of an Android app. Each components plays a specific role in an Android
app which serves a distinct purpose and has distinct life-cycles(the flow of how and when the component is created
and destroyed). Here are the four types of app components:
1. Activities: An activity represents a single screen with a User Interface(UI). An Android app may have more
than one activity. (e.g. an email app might have one activity to list all the emails, another to show the
contents of each email, and another to compose new email.) All the activities in an App work together to
create a User eXperience (UX).
2. Services: A service runs in the background to perform long-running operations or to perform work for a
remote processes. A service does not provide any UI, it runs only in the background with the User's input.
(e.g. a service can play music in the background while the user is in a different App, or it might download data
from the internet without blocking user's interaction with the Android device.)
3. Content Providers: A content provider manages shared app data. There are four ways to store data in an
app: it can be written to a file and stored in the file system, inserted or updated to a SQLite database, posted
to the web, or saved in any other persistent storage location the App can access. Through content providers,
other Apps can query or even modify the data. (e.g. Android system provides a content provider that
manages the user's contact information so that any app which has permission can query the contacts.)
Content providers can also be used to save the data which is private to the app for better data integrity.
4. Broadcast receivers: A broadcast receiver responds to the system-wide broadcasts of announcements (e.g.
a broadcast announcing that the screen has turned off, the battery is low, etc.) or from Apps (e.g. to let other
apps know that some data has been downloaded to the device and is available for them to use). Broadcast
receivers don't have UIs but they can show notification in the status bar to alert the user. Usually broadcast
receivers are used as a gateway to other components of the app, consisting mostly of activities and services.
One unique aspect of the Android system is that any app can start another app's component (e.g. if you want to
make call, send SMS, open a web page, or view a photo, there is an app which already does that and your app can
make use of it, instead of developing a new activity for the same task).
When the system starts a component, it starts the process for that app (if it isn't already running, i.e. only one
foreground process per app can run at any given time on an Android system) and instantiates the classes needed
for that component. Thus the component runs on the process of that App that it belongs to. Therefore, unlike apps
on other systems, Android apps don't have a single entry point(there is no main() method).
Because the system runs each app in a separate process, one app cannot directly activate another app's
components, however the Android system can. Thus to start another app's component, one app must send a
message to the system that specifies an intent to start that component, then the system will start that component.
Context
Instances of the class android.content.Context provide the connection to the Android system which executes the
application. Instance of Context is required to get access to the resources of the project and the global information
Let's have an easy to digest example: Consider you are in a hotel, and you want to eat something. You call room-
service and ask them to bring you things or clean up things for you. Now think of this hotel as an Android app,
yourself as an activity, and the room-service person is then your context, which provides you access to the hotel
resources like room-service, food items etc.
Yet an other example, You are in a restaurant sitting on a table, each table has an attendant, when ever you want to
order food items you ask the attendant to do so. The attendant then places your order and your food items gets
served on your table. Again in this example, the restaurant is an Android App, the tables or the customers are App
components, the food items are your App resources and the attendant is your context thus giving you a way to
access the resources like food items.
Activating any of the above components requires the context's instance. Not just only the above, but almost every
system resource: creation of the UI using views(discussed later), creating instance of system services, starting new
activities or services -- all require context.
an Android Virtual Device (AVD) definition lets you define the characteristics of an Android Phone, Tablet,
Android Wear, or Android TV device that you want to simulate in the Android Emulator. The AVD Manager
helps you easily create and manage AVDs.
5. Here you need to choose an Android version for your emulator. You might also need to download it first by
clicking Download. After you've chosen a version, click Next.
7. Now you got a new AVD ready for launching your apps on it.
De Wieringer paarden zijn niet zeer groot, doch sterk en taai, en zeer
geschikt voor zwaren arbeid.—
Het Wieringer schapenras weegt niet tegen dat van Texel op. Zij zijn kleiner
van stuk, en hunne wol is altijd lager in prijs, dan van de Texelsche
schapen.—
De uitvoer van vee, vooral gedurende den winter, van gemeste runderen, is
nog al aanzienlijk, maar bovenal is de handel in schapen groot. De
jaarlijksche uitvoer bedraagt gemiddeld 200 runderen, 1,000 oude schapen
en 5,000 lammeren, terwijl in 1853 de uitvoer van schapenkaas 8150 N. ℔
en van schapenwol 16,898 N. ℔ bedroeg.—
De uitvoer van schapenkaas vermindert echter zeer, aangezien men zich ook
op W i e r i n g e n meer en meer begint toe te leggen op het maken van de
gewone Noord-Hollandsche kaas, dat vrij goed schijnt te slagen.—
Verschijnselen van longziekte zijn hier tot nog toe niet waargenomen.—
Eene andere, hoogst belangrijke tak van industrie voor dit Eiland, is de
wiermaaijerij3.
Men maait de wier in de maanden Junij, Julij en Augustus, even als het
gewone gras, op de waarden, die met de ebbe op één voet of een half voet
na droog vallen. Men begint met half ebbe te maaijen, en heeft dan hooge
laarzen aan, die tot aan het midden des ligchaams reiken. Het gemaaide
wier wordt daarna in schuiten geladen, vervolgens op wagens overgeladen
zijnde, op het land uitgestrooid en vooral aan den invloed der zon
blootgesteld, waardoor voornamelijk de zoutdeelen er uittrekken. Na
verloop van ongeveer veertien dagen, brengt men het gedroogde wier in
sloten met zoet water, om gedurende een tiental dagen te ververschen.
Hierna wordt het opgehaald, en op het land gestrooid, waarna men het uit
elkander pluist, en, nadat het goed droog is, tot balen van p. m. 100 kilo,
zamenpakt, om naar Amsterdam, Rotterdam, zelfs naar België en het
noordelijke gedeelte van Frankrijk uitgevoerd te worden.
Het losgeraakte, niet gemaaide wier, wordt opgevischt en veelal aan den
zeedijk van het Eiland gebruikt, waartoe het door zijne pakking en
blijvende veerkracht zeer geschikt is.
Bij open winters gaan eenige personen in eene zeilschuit. Een hunner is
voorzien van een ijzeren werktuig, elger genaamd, dat aan eenen langen
stok bevestigd is, en bestaat uit eene soort van vork, met veerkrachtige
nijptanden. De visscher houdt dit werktuig onder het zeilen zoodanig, dat de
tanden door de slijk slepen, en de paling daartusschen bekneld wordt. Op
deze wijze kan de vangst soms zeer aanzienlijk wezen. Een getal van 40 à
50 schuiten wordt tot deze visscherij gebruikt.—De visscherij in de
binnenwateren levert bijna niets op.
1 Naar wij vernemen, bestaat er vooruitzigt op den aanleg van schelpwegen op het
Eiland W i e r i n g e n . Wij wenschen hartelijk, dat de Wieringers spoedig bevrijd mogen
worden van die onaangename zandwegen.
2 In den fraaijen en welvoorzienen tuin van den Heer Burgemeester, Mr. J. van Hengel,
zag ik eenen appelboom, die geplant werd den 1 April 1847. Den 1 Augustus van dat jaar,
leverde hij de eerste vruchten, 60 in getal; den 1 November, plukte men voor de tweede
maal de vruchten, ten getale van 80, terwijl deze zelfde boom in December
daaraanvolgende, op nieuw in vollen bloei stond.—In 1848 was de boom weder vol.—In
den boomgaard van den Heer D. Koorn, te Hypolitushoef, zag ik op een veld van 120
roeden, een 70 tal vruchtboomen staan, waarvan de meesten, (5 of 6 uitgezonderd) als met
vruchten bedekt waren. Inzonderheid was dit het geval met de jutten- en dirkjesperen.
3 Wier is een zeegras waarvan men wil, dat W i e r i n g e n (oudtijds W i r o m ,
W i r o n ) zijn naam ontleent. „Wier, bij de Latijnen Alga genaamd, is een zeekruit, dat in
zoute zeewateren, op hooge slikken en verdronke waarden en Landen zijne wortelen schiet,
en boven het gemeene water zijn loof, en dradige takjes of spruitsels vertoont, en de zee
alomme als een grasrijke weide voor onze oogen verbeeld. Oudtijds wierd het, als onnut tot
eenig gebruik, aangezien, noemende de Latijnsche Lierdichter Horatius hetzelve Od. 17,
lib. III, Alga Inutilis, onnut zeegras, zoodat men bij de Latijnen, eenige geringe, en niet
noemenswaardige zaak willende te kennen geven, en beteekenen, tot een spreekwoordt
zeide: Vilior Algâ, Slechter dan wier. (Zie denzelven Dichter lib. II, Serm. Satyr. V.) Maar
hedendaags is hetzelve, voornamentlijk in deze leege Landen, daar men van Duinen
ontbloot is, en de zee met Dijken moet afkeeren, in groot gebruik gekomen, en wordt voor
de beste stoffe gehouden, om op onze lichte en veenige gronden eenige Dijken te vestigen,
pakkende het wier zoo vast in elkaar, als de allerbeste kleijaarde, waardoor de zeegolven,
daartegen slaande, door de gladdigheit van de wier daar weder afrollen. Zoodat
meenigmaal bij de Staten van den Lande, Plakkaaten en Ordonnantiën op het visschen en
ophaalen van de wier gemaakt zijn.” (Toon. der Ver. Ned. door Halma.)
DERDE HOOFDSTUK.
GESCHIEDENIS VAN WIERINGEN.
Het tegenwoordige Eiland W i e r i n g e n , vroeger aan den vasten wal van
het oude West-Friesland verbonden, was, volgens eene in de 13de eeuw
ontworpen kaart, door den IJssel, welke rivier met den ouden
Flevumstroom in gemeenschap stond, en die zich daarna bij Vlieland in de
Noordzee ontlastte, van de Friesche kust gescheiden. Omtrent den tijd
echter, wanneer die afscheiding hebbe plaats gegrepen, verkeert men in het
onzekere, of althans, verschillende schrijvers zijn ten dien opzigte ook
verschillende meeningen toegedaan. In zooverre echter komen de meeste
geschiedkundigen met elkander overeen, dat W i e r i n g e n reeds in de
12de eeuw van het tegenwoordige Friesland, en in 1296, van het
tegenwoordige Noord-Holland (vroeger West-Friesland genoemd)
gescheiden was. Op de oudste der bestaande kaarten van dit gedeelte van
Neêrland’s tegenwoordig Rijksgebied, bespeuren wij den naam
W i e r i n g e n niet. Echter vinden wij, ter plaatse, waar dit Eiland ligt, en
wel bepaald op de hoogte van het het dorpje S t r o e , de namen Strude,
Wierum, en men mag veilig aannemen, dat, door deze laatste naam het
tegenwoordige W i e r i n g e n moet verstaan worden, dat reeds van af de
14de eeuw, dezen naam draagt, en dat in eene lijst of blaffert van de
Utrechtsche kerkgoederen, W i r o n wordt geheeten. Dienaangaande vinden
wij het volgende aangeteekend:
Halma, Toon. der V. Ned., II d., bl. 316.—D. Burger, Kron. van Medemb.,
Bronerius, Westfris. Illustr., 2 deel;—P. J. Twisk, Kron., I.—
Voorts vinden wij bij de reeds genoemde schrijvers, nog het volgende
vermeld:
Bronerius, Westfris. Illustr. 2e. deel; Plakkaatboek van Holl., 6 Se t. 1597; id. 5
Sept. 1603.—
Groot zijn dus de veranderingen, welke op dit Eiland, sedert de 12de eeuw,
door storm en watervloeden, hebben plaats gegrepen; vooral, wanneer wij
daarbij bedenken, dat sedert dien tijd al het land tusschen Stavoren,
Medemblik, Texel en W i e r i n g e n , in de diepte verzwolgen, en daarom
niets meer overig is, dan eenige zandbanken en platen.—
In 1421 leest men van de bevestiging der Privilegiën, aan deze Eilanders
geschonken, door Johan, Grave van Hollandt, bij verordening in dato den
4den Mei.
Bij Privilegie van den 8sten Mei 1432, verleend door Philips Palentein,
vindt men, dat „die hem (zich) uit noot verweert of manslag begaat is vrij
van den dood”; terwijl daarbij tevens bepaald werd, dat het W i e r i n g e r
geregt zich tot 500 roeden buiten het Eiland uitstrekte.—
Bij besluit van den 6 Maart 1515, verleende Keizer Karel V, vergunning,
tot de bedijking van W i e r i n g e n ; als mede het aanstellen van
Heemraden, in de maniere hunner regtspleging, en den 11den Junij 1621,
ontving de Regering van W i e r i n g e n , Approbatie van de Ridderschap
der Staten van Holland.—
Uit dit een en ander meenen wij te mogen afleiden, dat het gevoelen, dat
W i e r i n g e n zijnen naam ontleend hebbe aan de Wierdijken, op geene
genoegzame gronden van zekerheid rust, aangezien dit Eiland, reeds vòòr
de eerste bedijking, zijnen naam had ontvangen.—
Van de stichting der 4 parochiekerken op W i e r i n g e n , is weinig bekend.
Men vindt ze reeds vermeld in een Handvest of Privilegie van Filips,
Hertog van Bourgondië, Grave van West-Friesland, enz., in het 1ste Artikel,
uitgegeven op den 18den Mei des jaars 1452.
In vroegeren tijd bezat dit Eiland vele vaste goederen, waarvan de kerken
en pastoriën onderhouden, en de traktementen der predikanten, kosters en
voorzangers betaald werden. Die inkomsten werden geraamd, op ƒ 2500 ’s
jaars en konden, gerekend naar de behoeften van dien tijd, ruim toe. Doch
sedert 1767 zijn deze goederen ten behoeve van den Staat verkocht, zoodat
er bijna geene vaste goederen meer tot de Hervormde kerken behooren. De
onderscheidene diakoniën bezitten echter nog eenige vaste fondsen; vooral
die der Doopsgezinde en R. C. gemeenten.
In 1680 zijn, op last van Gecommitteerden Raden van het Noorder kwartier,
de beide klokken uit de torens der O o s t e r - en W e s t e r l a n d s c h e
kerken gehaald, naar Amsterdam vervoerd en daarna in den kerktoren aan
den Helder gehangen; terwijl er ten jare 1842, (welk jaar, door eene
buitengewone droogte, bij de W i e r i n g e r s nog lang in geheugenis zal
blijven) een klok uit de toren te H y p o l i t u s h o e f werd verkocht.
Inzonderheid was het jaar 1715 voor dit dorp noodlottig, als wanneer een
groot gedeelte van hetzelve door eenen hevigen brand geteisterd werd.
Gebrek aan behoorlijke brandbluschmiddelen, waarbij ook vooral de verre
afstand van het water kwam, belette de bevolking, om dit onheil met den
noodigen spoed te keer te kunnen gaan, en gaf aanleiding tot het graven van
eenen zeer grooten brandput, de B u r e n p u t geheeten, die in 1717 op
kleinen afstand van de Herv. kerk gegraven werd.
waarin:
waarin:
waarin:
Hypolitushoef, Belt,
Ooster-Klif, Normer,
Wester-Klif, Ooster-Elft,
Noord-Buren, Wester-Elft,
Zand-Buren, Holm.
waarin:
Westerland, Haukes,
Nood-Gest, De Quarantaine-Inrigting.
1. D e Q u a r a n t a i n e - I n r i g t i n g .
Deze inrigting, welke op de zuidwestelijke punt van het Eiland ligt, en door
de Eilanders doorgaans met den naam van „de Pesthuizen” bestempeld
wordt, werd hier ten jare 1806 gesticht, op eene oppervlakte van ruim 11
bunders. Over het algemeen wordt van deze inrigting weinig gebruik
gemaakt; nogthans bewees zij, tijdens het woeden van de cholera in
Noordelijk en Oostelijk Europa, belangrijke diensten. Voor ruim 25 jaren,
stierven aldaar meer dan tweehonderd Paltzers, aan evengenoemde ziekte,
welke op de begraafplaats te Westerland ter aarde werden besteld.
De Geneesheer houdt echter hier geen bepaald verblijf, maar wordt, des
noodig, van het Nieuwe Diep ontboden.
2. W e s t e r l a n d .
H. L. B.
LUITJE WIGBOUT
oud c. 35 jaren
11 Oct. 1825;
EN ZIJNE ZONEN:
CORNELIS WIGBOUT,
oud ruim 20 jaren;
JACOBUS WIGBOUT,
oud ruim 15 jaren.
Beide 10 Maart 1836.
Deez’ Vader en zijn Zoons, hier in de aard bedolven,
Verloren alle drie hun leven in de golven.
Den Koningsweg verlatende, rigten wij onze schreden noordwaarts tot den
Noorderweg, en begeven wij ons naar het gehucht
3. N o r m e r .
4. N o o r d - B u r e n ,
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
ebookbell.com