Resources & Tips
Code samples
These code samples are Java based Android covered during training sessions.
Simple Bluetooth scanner
https://github.com/tuttelikz/BluetoothSimple
Simple Bluetooth socket for communication with Arduino HC05, HC06
https://github.com/tuttelikz/BluetoothSocketSimple
Simple Camera intent
https://github.com/tuttelikz/CameraSimple
Simple Video Overlay into AR Scene
https://github.com/tuttelikz/ARVideoSimple
Simple WiFi scanner
https://github.com/tuttelikz/WifiSimple
Error reports
Android Emulator Hypervisor Driver for AMD Processors installation failed
1. BIOS - SVM Module → Enable (reboot)
2. Windows Features - Hyper-V & Windows sandbox & Windows Hypervisor Platform → Disable (reboot)
SD card shows little memory
- Open Disk management
- Delete all the partitions associated with that SD (be very careful that the partitions you are deleting are associated with the SD)
- After all the partitions have been deleted you will see at the bottom of the Disk management UI an allocated large partition, this will be your unformatted SD card (you may need to refresh). Right click on it, Choose New Simple Volume from the shortcut menu. Click the Next button.
- Set the size of the new volume (it is preset to disk capacity). Click the Next button.
- Name the new drive. Choose a name if you want.
- Choose format. (NTFS, FAT32)
- Click the Next button then Finish button and you are done.
Hands-on & Tutorials
Google Developers Codelabs
Provide a guided, tutorial, hands-on coding experience. Most codelabs will step you through the process of building a small application, or adding a new feature to an existing application. They cover a wide range of topics such as Android Wear, Google Compute Engine, Project Tango, and Google APIs on iOS:
Google Developers Training
- End-to-end Android development Codelab-based training courses
Knowledge base
Documentation and References
Kotlin reference
https://kotlinlang.org/docs/reference/
Kotlin Koans
https://play.kotlinlang.org/koans/overview
Terminology
Design
dp vs. sp
dp
: for UI elements
sp
: for text sizes
Converting dp units to pixels
px = dp * (dpi / 160)
Density qualifiers:
ldpi
: Resources for low-density (ldpi) screens (~120dpi).
mdpi
: Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi
: Resources for high-density (hdpi) screens (~240dpi).
xhdpi
: Resources for extra-high-density (xhdpi) screens (~320dpi).
xxhdpi
: Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
xxxhdpi
: Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi).
nodpi
: Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
tvdpi
: Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
Practical tips & libraries
Android
ADB
ADB location
Check to add adb location to the end of PATH of environment variables. Eg: "C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools
" to path
How to Run ADB wireless
Step 1. Connect phone with USB:
adb tcpip 5555
Step 2. Disconnect phone from USB
adb connect device_ip_address
Step 3. Run scrcpy (maybe necessary to put -s "YOUR SERIAL NUMBER")
scrcpy --bit-rate 2M --max-size 800
Take screenshot/screencast from Android
Capture screenshot on mobile and save to PC:
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png ./screen.png
Capture screencast on mobile and save to PC:
adb shell screenrecord /sdcard/screen.mp4
adb pull /sdcard/screen.mp4 .
Extra:
Deleting file: adb shell rm /sdcard/screen.png
Opening file: open ./screen.png
OpenCV on Android:
Build OpenCV 4.4.0 for Android:
https://www.youtube.com/watch?v=HgN-deEeHeQ&list=PLwfJJiO20qkB7EhtRITL3znme8mIgOwID&index=9&t=2s
Advices
Qualities of great app:
- Effective
- Efficient
- Beautiful
- Accessible
App Permissions
Check app permissions. Sometimes this can cause you error when Android app does not receive any information.
Emulator skins
Procedure how to add custom emulator skin
- Tools → AVD Manager (Android Virtual Device)
- Create Virtual Device
- New Hardware Profile
- Change:
- Device Name, ex: Samsung S20 Ultra (Black)
- Screen, ex: 6.9 inch, 1440 x 3200 px
- Default Skin (...) → Choose path to unzipped folder
- Finish
- Select Hardware (Samsung S20 Ultra (Black)) → Next
- Select a system image (Q, Android 10.0) → Next
- Set AVD Name (Samsung S20 Ultra (Black)) → Finish
Emulator skin files
Galaxy S20 Ultra:
- Display: 6.9 inches (~89.9% screen-to-body ratio)
- Resolution: 1440 x 3200 pixels (~511 ppi density)
- Color: âš«
Galaxy S20+:
- Display: 6.7 inches (~90.5% screen-to-body ratio)
- Resolution: 1440 x 3200 pixels (~525 ppi density)
- Color: âš«
Galaxy S20:
- Display: 6.2 inches (~89.5% screen-to-body ratio)
- Resolution1440 x 3200 pixels (~563 ppi density)
- Color: âš«
USB debuging
- Activate "USB Debugging" options to see the device in Android Studio
Microcontrollers
Pins: Analog | Digital
Analog pins and Digital pins serve different purpose on microcontrollers, eg. Arduino. Digital pins give you either 1 or 0, whereas analog pin values have wider range.
Rename Bluetooth Module
You can put custom defined names and password to Bluetooth. Follow Week 3.
Textbooks
Android
Microcontrollers
Android Lecture Summary (Fast Campus, Korean)
Videos
Edge TPU
Introducing Google Coral: Building On-Device AI (Google I/O'19)
Linux
AT&T Archives: The UNIX Operating System
Android
Runtime Permissions in Android (Marshmallow 6.0)
Density-independent Pixels