The 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
Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners
https://goalkicker.com/
Content
1-1
Content list
1-2
About
1-3
Chapter 1: Getting started with Android
1-4
Section 1.1: Creating a New Project
1-5
Section 1.2: Setting up Android Studio
1-6
Section 1.3: Android programming without an IDE
1-7
Section 1.4: Application Fundamentals
1-8
Section 1.5: Setting up an AVD (Android Virtual Device)
1-9
Chapter 2: Android Studio
1-10
Section 2.1: Setup Android Studio
1-11
Section 2.2: View And Add Shortcuts in Android Studio
1-12
Section 2.3: Android Studio useful shortcuts
1-13
Section 2.4: Android Studio Improve performance tip
1-14
Section 2.5: Gradle build project takes forever
1-15
Section 2.6: Enable/Disable blank line copy
1-16
Section 2.7: Custom colors of logcat message based on message importance
1-17
Section 2.8: Filter logs from UI
1-18
Section 2.9: Create filters configuration
1-19
Section 2.10: Create assets folder
1-20
Chapter 3: Instant Run in Android Studio
1-21
Section 3.1: Enabling or disabling Instant Run
1-22
Section 3.2: Types of code Swaps in Instant Run
1-23
Section 3.3: Unsupported code changes when using Instant Run
1-24
Chapter 4: TextView
1-25
Section 4.1: Spannable TextView
1-26
Section 4.2: Strikethrough TextView
1-27
Section 4.3: TextView with image
1-28
Section 4.4: Make RelativeSizeSpan align to top
1-29
Section 4.5: Pinchzoom on TextView
1-30
Section 4.6: Textview with dierent Textsize
1-31
Section 4.7: Theme and Style customization
1-32
Section 4.8: TextView customization
1-33
Section 4.9: Single TextView with two dierent colors
1-34
Chapter 5: AutoCompleteTextView
1-35
Section 5.1: AutoComplete with CustomAdapter, ClickListener and Filter
Section 47.20: Executing a shell script from gradle
1-315
Section 47.21: Show all gradle project tasks
1-316
Section 47.22: Debugging your Gradle errors
1-317
Section 47.23: Use gradle.properties for central versionnumber/buildconfigurations
1-318
Section 47.24: Defining build types
1-319
Chapter 48: FileIO with Android
1-320
Section 48.1: Obtaining the working folder
1-321
Section 48.2: Writing raw array of bytes
1-322
Section 48.3: Serializing the object
1-323
Section 48.4: Writing to external storage (SD card)
1-324
Section 48.5: Solving "Invisible MTP files" problem
1-325
Section 48.6: Working with big files
1-326
Chapter 49: FileProvider
1-327
Section 49.1: Sharing a file
1-328
Chapter 50: Storing Files in Internal & External Storage
1-329
Section 50.1: Android: Internal and External Storage - Terminology Clarification
1-330
Section 50.2: Using External Storage
1-331
Section 50.3: Using Internal Storage
1-332
Section 50.4: Fetch Device Directory :
1-333
Section 50.5: Save Database on SD Card (Backup DB on SD)
1-334
Chapter 51: Zip file in android
1-335
Section 51.1: Zip file on android
1-336
Chapter 52: Unzip File in Android
1-337
Section 52.1: Unzip file
1-338
Chapter 53: Camera and Gallery
1-339
Section 53.1: Take photo
1-340
Section 53.2: Taking full-sized photo from camera
1-341
Section 53.3: Decode bitmap correctly rotated from the uri fetched with the intent
1-342
Section 53.4: Set camera resolution
1-343
Section 53.5: How to start camera or gallery and save camera result to storage
1-344
Chapter 54: Camera 2 API
1-345
Section 54.1: Preview the main camera in a TextureView
1-346
Chapter 55: Fingerprint API in android
1-347
Section 55.1: How to use Android Fingerprint API to save user passwords
1-348
Section 55.2: Adding the Fingerprint Scanner in Android application
1-349
Chapter 56: Bluetooth and Bluetooth LE API
1-350
Section 56.1: Permissions
1-351
Section 56.2: Check if bluetooth is enabled
1-352
Section 56.3: Find nearby Bluetooth Low Energy devices
1-353
Section 56.4: Make device discoverable
1-354
Section 56.5: Connect to Bluetooth device
1-355
Section 56.6: Find nearby bluetooth devices
1-356
Chapter 57: Runtime Permissions in API-23 +
1-357
Section 57.1: Android 6.0 multiple permissions
1-358
Section 57.2: Multiple Runtime Permissions From Same Permission Groups
1-359
Section 57.3: Using PermissionUtil
1-360
Section 57.4: Include all permission-related code to an abstract base class and extend the activity of this base class to achieve cleaner/reusable code
1-361
Section 57.5: Enforcing Permissions in Broadcasts, URI
1-362
Chapter 58: Android Places API
1-363
Section 58.1: Getting Current Places by Using Places API
1-364
Section 58.2: Place Autocomplete Integration
1-365
Section 58.3: Place Picker Usage Example
1-366
Section 58.4: Setting place type filters for PlaceAutocomplete
1-367
Section 58.5: Adding more than one google auto complete activity
1-368
Chapter 59: Android NDK
1-369
Section 59.1: How to log in ndk
1-370
Section 59.2: Building native executables for Android
1-371
Section 59.3: How to clean the build
1-372
Section 59.4: How to use a makefile other than Android.mk
1-373
Chapter 60: DayNight Theme (AppCompat v23.2 / API 14+)
1-374
Section 60.1: Adding the DayNight theme to an app
1-375
Chapter 61: Glide
1-376
Section 61.1: Loading an image
1-377
Section 61.2: Add Glide to your project
1-378
Section 61.3: Glide circle transformation (Load image in a circular ImageView)
1-379
Section 61.4: Default transformations
1-380
Section 61.5: Glide rounded corners image with custom Glide target
1-381
Section 61.6: Placeholder and Error handling
1-382
Section 61.7: Preloading images
1-383
Section 61.8: Handling Glide image load failed
1-384
Section 61.9: Load image in a circular ImageView without custom transformations
1-385
Chapter 62: Dialog
1-386
Section 62.1: Adding Material Design AlertDialog to your app using Appcompat
1-387
Section 62.2: A Basic Alert Dialog
1-388
Section 62.3: ListView in AlertDialog
1-389
Section 62.4: Custom Alert Dialog with EditText
1-390
Section 62.5: DatePickerDialog
1-391
Section 62.6: DatePicker
1-392
Section 62.7: Alert Dialog
1-393
Section 62.8: Alert Dialog with Multi-line Title
1-394
Section 62.9: Date Picker within DialogFragment
1-395
Section 62.10: Fullscreen Custom Dialog with no background and no title
1-396
Chapter 63: Enhancing Alert Dialogs
1-397
Section 63.1: Alert dialog containing a clickable link
1-398
Chapter 64: Animated AlertDialog Box
1-399
Section 64.1: Put Below code for Animated dialog..
1-400
Chapter 65: GreenDAO
1-401
Section 65.1: Helper methods for SELECT, INSERT, DELETE, UPDATE queries
1-402
Section 65.2: Creating an Entity with GreenDAO 3.X that has a Composite Primary Key
1-403
Section 65.3: Getting started with GreenDao v3.X
1-404
Chapter 66: Tools Attributes
1-405
Section 66.1: Designtime Layout Attributes
1-406
Chapter 67: Formatting Strings
1-407
Section 67.1: Format a string resource
1-408
Section 67.2: Formatting data types to String and vise versa
1-409
Section 67.3: Format a timestamp to string
1-410
Chapter 68: SpannableString
1-411
Section 68.1: Add styles to a TextView
1-412
Section 68.2: Multi string , with multi color
1-413
Chapter 69: Notifications
1-414
Section 69.1: Heads Up Notification with Ticker for older devices
1-415
Section 69.2: Creating a simple Notification
1-416
Section 69.3: Set custom notification - show full content text
1-417
Section 69.4: Dynamically getting the correct pixel size for the large icon
1-418
Section 69.5: Ongoing notification with Action button
1-419
Section 69.6: Setting Dierent priorities in notification
1-420
Section 69.7: Set custom notification icon using `Picasso` library
1-421
Section 69.8: Scheduling notifications
1-422
Chapter 70: AlarmManager
1-423
Section 70.1: How to Cancel an Alarm
1-424
Section 70.2: Creating exact alarms on all Android versions
1-425
Section 70.3: API23+ Doze mode interferes with AlarmManager
1-426
Section 70.4: Run an intent at a later time
1-427
Chapter 71: Handler
1-428
Section 71.1: HandlerThreads and communication between Threads
1-429
Section 71.2: Use Handler to create a Timer (similar to javax.swing.Timer)
1-430
Section 71.3: Using a Handler to execute code after a delayed amount of time
1-431
Section 71.4: Stop handler from execution
1-432
Chapter 72: BroadcastReceiver
1-433
Section 72.1: Using LocalBroadcastManager
1-434
Section 72.2: BroadcastReceiver Basics
1-435
Section 72.3: Introduction to Broadcast receiver
1-436
Section 72.4: Using ordered broadcasts
1-437
Section 72.5: Sticky Broadcast
1-438
Section 72.6: Enabling and disabling a Broadcast Receiver programmatically
1-439
Section 72.7: Example of a LocalBroadcastManager
1-440
Section 72.8: Android stopped state
1-441
Section 72.9: Communicate two activities through custom Broadcast receiver
1-442
Section 72.10: BroadcastReceiver to handle BOOT_COMPLETED events
1-443
Section 72.11: Bluetooth Broadcast receiver
1-444
Chapter 73: UI Lifecycle
1-445
Section 73.1: Saving data on memory trimming
1-446
Chapter 74: HttpURLConnection
1-447
Section 74.1: Creating an HttpURLConnection
1-448
Section 74.2: Sending an HTTP GET request
1-449
Section 74.3: Reading the body of an HTTP GET request
1-450
Section 74.4: Sending an HTTP POST request with parameters
1-451
Section 74.5: A multi-purpose HttpURLConnection class to handle all types of HTTP requests
1-452
Section 74.6: Use HttpURLConnection for multipart/form-data
1-453
Section 74.7: Upload (POST) file using HttpURLConnection
1-454
Chapter 75: Callback URL
1-455
Section 75.1: Callback URL example with Instagram OAuth
1-456
Chapter 76: Snackbar
1-457
Section 76.1: Creating a simple Snackbar
1-458
Section 76.2: Custom Snack Bar
1-459
Section 76.3: Custom Snackbar (no need view)
1-460
Section 76.4: Snackbar with Callback
1-461
Section 76.5: Snackbar vs Toasts: Which one should I use?
1-462
Section 76.6: Custom Snackbar
1-463
Chapter 77: Widgets
1-464
Section 77.1: Manifest Declaration -
1-465
Section 77.2: Metadata
1-466
Section 77.3: AppWidgetProvider Class
1-467
Section 77.4: Create/Integrate Basic Widget using Android Studio
1-468
Section 77.5: Two widgets with dierent layouts declaration
1-469
Chapter 78: Toast
1-470
Section 78.1: Creating a custom Toast
1-471
Section 78.2: Set position of a Toast
1-472
Section 78.3: Showing a Toast Message
1-473
Section 78.4: Show Toast Message Above Soft Keyboard
1-474
Section 78.5: Thread safe way of displaying Toast (Application Wide)
1-475
Section 78.6: Thread safe way of displaying a Toast Message (For AsyncTask)
1-476
Chapter 79: Create Singleton Class for Toast Message
1-477
Section 79.1: Create own singleton class for toast massages
1-478
Chapter 80: Interfaces
1-479
Section 80.1: Custom Listener
1-480
Section 80.2: Basic Listener
1-481
Chapter 81: Animators
1-482
Section 81.1: TransitionDrawable animation
1-483
Section 81.2: Fade in/out animation
1-484
Section 81.3: ValueAnimator
1-485
Section 81.4: Expand and Collapse animation of View
1-486
Section 81.5: ObjectAnimator
1-487
Section 81.6: ViewPropertyAnimator
1-488
Section 81.7: Shake animation of an ImageView
1-489
Chapter 82: Location
1-490
Section 82.1: Fused location API
1-491
Section 82.2: Get Address From Location using Geocoder
1-492
Section 82.3: Requesting location updates using LocationManager
1-493
Section 82.4: Requesting location updates on a separate thread using LocationManager
1-494
Section 82.5: Getting location updates in a BroadcastReceiver
1-495
Section 82.6: Register geofence
1-496
Chapter 83: Theme, Style, Attribute
1-497
Section 83.1: Define primary, primary dark, and accent colors
1-498
Section 83.2: Multiple Themes in one App
1-499
Section 83.3: Navigation Bar Color (API 21+)
1-500
Section 83.4: Use Custom Theme Per Activity
1-501
Section 83.5: Light Status Bar (API 23+)
1-502
Section 83.6: Use Custom Theme Globally
1-503
Section 83.7: Overscroll Color (API 21+)
1-504
Section 83.8: Ripple Color (API 21+)
1-505
Section 83.9: Translucent Navigation and Status Bars (API 19+)
1-506
Section 83.10: Theme inheritance
1-507
Chapter 84: MediaPlayer
1-508
Section 84.1: Basic creation and playing
1-509
Section 84.2: Media Player with Buer progress and play position
1-510
Section 84.3: Getting system ringtones
1-511
Section 84.4: Asynchronous prepare
1-512
Section 84.5: Import audio into androidstudio and play it
1-513
Section 84.6: Getting and setting system volume
1-514
Chapter 85: Android Sound and Media
1-515
Section 85.1: How to pick image and video for api >19
1-516
Section 85.2: Play sounds via SoundPool
1-517
Chapter 86: MediaSession
1-518
Section 86.1: Receiving and handling button events
1-519
Chapter 87: MediaStore
1-520
Section 87.1: Fetch Audio/MP3 files from specific folder of device or fetch all files
1-521
Chapter 88: Multidex and the Dex Method Limit
1-522
Section 88.1: Enabling Multidex
1-523
Section 88.2: Multidex by extending Application
1-524
Section 88.3: Multidex by extending MultiDexApplication
1-525
Section 88.4: Multidex by using MultiDexApplication directly
1-526
Section 88.5: Counting Method References On Every Build (Dexcount Gradle Plugin)
1-527
Chapter 89: Data Synchronization with Sync Adapter
1-528
Section 89.1: Dummy Sync Adapter with Stub Provider
1-529
Chapter 90: PorterDu Mode
1-530
Section 90.1: Creating a PorterDu ColorFilter
1-531
Section 90.2: Creating a PorterDu XferMode
1-532
Section 90.3: Apply a radial mask (vignette) to a bitmap using PorterDuXfermode
1-533
Chapter 91: Menu
1-534
Section 91.1: Options menu with dividers
1-535
Section 91.2: Apply custom font to Menu
1-536
Section 91.3: Creating a Menu in an Activity
1-537
Chapter 92: Picasso
1-538
Section 92.1: Adding Picasso Library to your Android Project
1-539
Section 92.2: Circular Avatars with Picasso
1-540
Section 92.3: Placeholder and Error Handling
1-541
Section 92.4: Re-sizing and Rotating
1-542
Section 92.5: Disable cache in Picasso
1-543
Section 92.6: Using Picasso as ImageGetter for Html.fromHtml
1-544
Section 92.7: Cancelling Image Requests using Picasso
1-545
Section 92.8: Loading Image from external Storage
1-546
Section 92.9: Downloading image as Bitmap using Picasso
1-547
Section 92.10: Try oine disk cache first, then go online and fetch the image
1-548
Chapter 93: RoboGuice
1-549
Section 93.1: Simple example
1-550
Section 93.2: Installation for Gradle Projects
1-551
Section 93.3: @ContentView annotation
1-552
Section 93.4: @InjectResource annotation
1-553
Section 93.5: @InjectView annotation
1-554
Section 93.6: Introduction to RoboGuice
1-555
Chapter 94: ACRA
1-556
Section 94.1: ACRAHandler
1-557
Section 94.2: Example manifest
1-558
Section 94.3: Installation
1-559
Chapter 95: Parcelable
1-560
Section 95.1: Making a custom object Parcelable
1-561
Section 95.2: Parcelable object containing another Parcelable object
1-562
Section 95.3: Using Enums with Parcelable
1-563
Chapter 96: Retrofit2
1-564
Section 96.1: A Simple GET Request
1-565
Section 96.2: Debugging with Stetho
1-566
Section 96.3: Add logging to Retrofit2
1-567
Section 96.4: A simple POST request with GSON
1-568
Section 96.5: Download a file from Server using Retrofit2
1-569
Section 96.6: Upload multiple file using Retrofit as multipart
1-570
Section 96.7: Retrofit with OkHttp interceptor
1-571
Section 96.8: Header and Body: an Authentication Example
1-572
Section 96.9: Uploading a file via Multipart
1-573
Section 96.10: Retrofit 2 Custom Xml Converter
1-574
Section 96.11: Reading XML form URL with Retrofit 2
1-575
Chapter 97: ButterKnife
1-576
Section 97.1: Configuring ButterKnife in your project
1-577
Section 97.2: Unbinding views in ButterKnife
1-578
Section 97.3: Binding Listeners using ButterKnife
1-579
Section 97.4: Android Studio ButterKnife Plugin
1-580
Section 97.5: Binding Views using ButterKnife
1-581
Chapter 98: Volley
1-582
Section 98.1: Using Volley for HTTP requests
1-583
Section 98.2: Basic StringRequest using GET method
1-584
Section 98.3: Adding custom design time attributes to NetworkImageView
1-585
Section 98.4: Adding custom headers to your requests [e.g. for basic auth]
1-586
Section 98.5: Remote server authentication using StringRequest through POST method
1-587
Section 98.6: Cancel a request
1-588
Section 98.7: Request JSON
1-589
Section 98.8: Use JSONArray as request body
1-590
Section 98.9: Boolean variable response from server with json request in volley
1-591
Section 98.10: Helper Class for Handling Volley Errors
1-592
Chapter 99: Date and Time Pickers
1-593
Section 99.1: Date Picker Dialog
1-594
Section 99.2: Material DatePicker
1-595
Chapter 100: Localized Date/Time in Android
1-596
Section 100.1: Custom localized date format with DateUtils.formatDateTime()
1-597
Section 100.2: Standard date/time formatting in Android
1-598
Section 100.3: Fully customized date/time
1-599
Chapter 101: Time Utils
1-600
Section 101.1: To check within a period
1-601
Section 101.2: Convert Date Format into Milliseconds
1-602
Section 101.3: GetCurrentRealTime
1-603
Chapter 102: In-app Billing
1-604
Section 102.1: Consumable In-app Purchases
1-605
Section 102.2: (Third party) In-App v3 Library
1-606
Chapter 103: FloatingActionButton
1-607
Section 103.1: How to add the FAB to the layout
1-608
Section 103.2: Show and Hide FloatingActionButton on Swipe
1-609
Section 103.3: Show and Hide FloatingActionButton on Scroll
1-610
Section 103.4: Setting behaviour of FloatingActionButton
1-611
Chapter 104: Touch Events
1-612
Section 104.1: How to vary between child and parent view group touch events