Welcome to Bin’s blog.
Latest Articles
-
Suspend Under The Hood
-
Kotlin Coroutine Async Launch
launch
Starts a new coroutine and doesn’t return the result to the caller.
-
Testing Coroutine
Testing Coroutines in Android
Invoking suspending functions in tests
runTest{}
is a coroutine builder designed for testing. ``` suspend fun fetchData(): String { delay(1000L) return “Hello world” } -
Coroutine Android Best Practices
Best practices for coroutines in Android
-
Coroutine Intro
Introduction
Feature
Lightweight
Suspension
Multi coroutinues can be run on one thread due to support for suspension, which doesn’t block the thread where coroutine is running.
-
Apksigner Unsupportedclassversionerror
Error description
Error: A JNI error has occurred, please check your installation and try again Exception in thread “main” java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:756) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
-
Adnroid Wifi Adb
Enable Wifi ADB
- Connect device to computer with cable.
- Ensure your device and computer are in save network, like connect to same wifi.
- Find out your device ip address, such as 172.10.10.5
- In terminal, command: adb tcpip 5555
- In terminal, command: adb connect ip:5555, such as 172.10.10.5: 5555
-
Kotlin Vocabulary Readnote Suspend
-
Kotlin Vocabulary Readnote Inline Function
When to use inline function
- For function with higher order function (lambda), make the function inline will save some memory by avoiding Function object creation.
-
Kotlin Vocabulary Readnote D8 R8 Enum
How Java Enum works in switch statement
Look Into Bytecode
I write a demo code which will be compiled to bytecode later, which will show how switch with Enum works internally. ```Java public class EnumDemo {
-
Kotlin Vocabulary Readnote Collections Sequence
ReadNote of Collections and sequences in Kotlin
Kotlin Standard Library offers two ways of working with containers: eagerly - with collections, and lazily - with sequences.
-
Kotlin Vocabulary Readnote Sealed Class
Sealed classes
Sealed class vs Enum class vs Ordinary class
Enum class
pros
- Used in when block, IDE will help check all branches.
-
Hpbn 101.2 Read Note
Three way handshake
- SYN
-
Java Collections Interface Set
The Set Interface
A Set is a Collection that cannot contain duplicate elements. To achieve this, Set applies a stronger contract on
equals()
andhashCode()
method. -
Java Collections Interface List
The List Interface
-
Java Collections Interface Collection
Java Collection Framework
-
Kotin Variable Number Of Arguments (varargs)
IllegalFormatConversionException
IllegalFormatConversionException was thrown when call TextView.setText2(R.strinig.placeholder, 2) and it works well with TextView.setText1(R.strinig.placeholder, 2). The key to resolve this error is use of spread operator.
-
Computer Network Week2
The Network Layer
-
Computer Network Week1
TCP/IP Five Layer Model
- Application Layer (Http…)
- Transport Layer (TCP, UDP)
- Network Layer (Wide Area Network)
- Data Link Layer (Local Area Network)
- Physical Layer (Cable, Fiber)
-
Rpc Study Road Map
Why RPC is important?
Remote Method Call is to solve how to pass messages in distributed system. The stability and performance of RPC will affect the whole system.
-
Basic Programming Model Read Note
Programming Model Selected questions
What is the value of Math.abs(-2147483648)?
Ans. -2147483648
-
Typescript Study Note
var
,let,
constand
readonly`There are two types of scopes in javascript, that is:
- Local scope(Function scope)
- Global scope
-
Introduction To Typescript Read Note
Read note of TypeScript Basics
-
Enter Doze Mode With Adb
Enter Doze mode
There are three stages for these steps:
- Prepare: Mock unplug and enable deviceidle.
- Go through doze modes step by step.
- Reset: Disable deviceidle and reset battery.
-
Get First Image From Gif With Fresco
Get first image from GIF with Fresco Sync & Async
Fresco did not provides a Sync way to get bitmap from DataSource, but we can use SimpleSettableFuture from ReactNative. However, we can write our own SettableFuture like what ReactNative done.
-
Decide A Local Uri In Android
Detect Local Uri in Android
-
Convert Callback To Sync Operation Using Countdownlatch
Convert Async to Sync Call Using Future and CountDownLatch
If a sync method call is wanted while API only provides async callback, we can con convert it to sync method call with Future and CountDownLatch.
-
Detect Image Format Using Java
Detect image format in Java
-
Incompatibleclasschangeerror Kotlin Java Inheritance
IncompatibleClassChangeError using Kotlin with Java
-
Android Binder Study Note
TL,DR
- Driver based IPC.
- There is only one copy for Binder IPC and hence its efficient.
- For client: Copy data from user space to kernel space, 1 time.
- For server: Using mmap to share response memory, 0 time.
-
Marquee Long Text In Textview
TL;DR
Use android:singline=”true” and make the TextView selected
-
Android Studio Custom Todo
TODO In Android Studio
There is a tool window named TODO in Android Studio, from which we can find all ‘TODO’ tags in our project. Besides the built in TODO and FIXME tag, Android Studio provides us with custom tags.
-
Interactive Rebase Using Sourcetree
Interactive rebase using SourceTree
-
Annotations For Java Friendly Kotlin Translate
Annotations for Java friendly code
-
Use Ui Automator Viewer To Get Current Viewer
What is UI Automator Viewer?
The uiautomatorviewer tool provides a convenient GUI to scan and analyze the UI components currently displayed on an Android device. – From developer.android.com
-
Intro To Ashmem Note
TL;DR
- Ashmem memory dies when the process dies.
- Ashmem allows fork first and then share memory.
- Ashmem save memory by unpinning memory pages, reclaim unit for ashmem is section.