Testing resumable uploads

The core idea behind resumable upload is straightforward if you are uploading a big file, then you are going to encounter users in the network conditions where they cannot upload the file in a single network session. The client-side code, to avoid restarting the file upload from the beginning, must figure out what portion of the file was uploaded and “resume” the upload of the rest. How to do resumable upload Before starting the upload, send a unique ID generated from the file contents to the server like MD-5 or SHA-256....

How to speed up HTML5 videos

Some video streaming websites like YouTube provides an option for speeding up/slowing down videos; some don’t. The trick is simple, find out the Video object via Js 1 document.querySelector("video") and then set its playbackRate property to the desired value Js 1 document.querySelector("video").playbackRate = 2.0; // For 2X speed-up These changes have to be made in the Developer console in Chrome or Browser console in Firefox.

Architecting Android apps for emerging markets

This is a long post. It covers several decisions like API version, distribution beyond play store, UI & network performance, and minimizing RAM, disk, and battery usage.

Introducing adb-enhanced: A swiss army knife for Android development

Android development requires tons of disconnected approaches for development and testing. Consider some scenarios To test runtime permission - Go to Settings -> Applications -> Application info of the app you are looking for and disable that permission. To test a fresh install - adb shell pm clear-data com.example To test your app under the battery-saver mode - turn on the battery saver mode by expanding the notification bar To stop the execution of an app - kill it via activity manager, adb shell am kill com....

Swift, Kotlin, and Go

It is impressive to see the amount of similarity which exists in Swift, Kotlin and Go, the three new languages for iOS, Android, and server-development respectively. Consider a simple, Hello World program. Swift Swift 1 2 3 4 5 func printHello() { // Type automatically inferred to string let name = "Ashish" // let declares a read-only variable print("Hello world from \(name)!") } Kotlin Kotlin 1 2 3 4 5 fun printHello() { // Type automatically inferred to string val name = "Ashish" // val declares a read-only value, var declares a read-write variable println("Hello world from ${name}") } Go...

Android: The right way to pull SQLite database

Let’s say you are developing an Android app com.example.android and want to access its database file named “content” from the test device/emulator. To access this file, located in app’s database directory, on both rooted and unrooted device would be Bash 1 2 3 4 5 $ APP_NAME=com.example.android $ adb shell run-as $APP_NAME cp databases/content.db /sdcard/content.db && $ adb pull /sdcard/content.db content.db && $ adb shell rm /sdcard/content.db ... This seems to work but is incorrect....

Diagnosing Mac apps which won't open (error -10810)

Occasionally, my mac applications end up in a corrupt state where they won’t open. I recently encountered this with Deluge. The first step to diagnose is to open Terminal and open them in the terminal via Sh 1 2 $ open -a deluge # This name is same as the name of the app (minus the ".app" portion). LSOpenURLsWithRole() failed for the application /usr/local/Caskroom/deluge/1.3.12/Deluge.app with error -10810. Now, the error is more diagnosable but still cryptic....

Java Musings - initializing a final variable with an uninitialized final variable

Java has fewer quirks compared to C++, but sometimes I do come across surprises. A code like following will fail to compile since you are trying to initialize a variable with an uninitialized variable. Java 1 2 3 4 5 6 7 8 9 public class Sample { private final String mField1; private final String mField2 = mField1 + " two"; private Sample(String field1) { mField1 = field1; } } But if instead of directly referencing mField1, you reference indirectly via a getter method code will compile, and mField2 will get “null” value for mField1....

Application Not Responding (ANR)

Demystifying Android rendering: Jank and ANR

Almost everyone developing an Android app has seen something like this in their device logs. Bash 1 I/Choreographer(1200): Skipped 60 frames! The application may be doing too much work on its main thread. On most devices, the Android platform tries to render a new frame every 16 milliseconds (60 fps). The rendering requires that whatever work is happening on the UI thread should finish in that timeframe (well, actually in less than that)....

Built-in "Developer options" in Android

Android has a few really good settings built right into the platform for debugging under a hidden “Developer Options” menu. You can turn them on via Settings -> About Phone -> Build Number (tap 7 times). The steps will be similar but might vary a bit across OEMs. In older versions of Android, this used to be an explicit option under the Settings tab. I find the following options to be useful for the development...