• Uncategorized
  • Reading to optional variable from NSData in Swift

    Interesting. func doStuff(arr: Array) { var value: UInt8!// = 0 let data = NSData(bytes: arr, length: arr.count * sizeof(UInt8)) data.getBytes(&value, range: NSMakeRange(0, 1)) println(value) } let arr: [UInt8] = [ 0x00, 0x34, 0x56, 0xFF ] doStuff(arr) value will be nil if 0x00 is read from NSData. In case value is not declared as Optional, 0 […]

  • Uncategorized
  • Generating JNI headers

    1. Build the project, e.g. gradlew build 2. Go to the directory you want to place the headers (e.g. src/main), and execute: javah -d jni -classpath ~/Library/Android/sdk/platforms/android-22/android.jar:../../build/intermediates/classes/debug {fully.qualified.class.name} This will place the auto-generated headers in the src/main/jni directory. Change the platform version in front of android.jar as appropriate.

  • Android
  • TaskStackBuilder broken?

    Perhaps not broken, but documented inadequately. In http://developer.android.com/training/implementing-navigation/temporal.html there’s a simple guide on how to set up back stack navigation when opening an app e.g. from a notification using a “deep link” to an activity that is not the topmost one in the app, so that the user can navigate upwards in the stack by pressing the […]

  • Uncategorized
  • Reusing existing fragments

    I’m currently in the process of making the landscape support in LoanShark more robust. When in portrait mode, the main activity displays a list of loans, while the view loan activity, opened by selecting an item from the list, displays the selected loans’ details. In landscape orientation both views are visible. These are all implemented […]

  • Android
  • Workaround for italics texts clipping

    TextView with italics text gets cropped at the rightmost edge when the view is set to wrap_content. Reportedly this affects when the content is set to have gravity=”right” as well. http://stackoverflow.com/q/4353836 I haven’t plunged into the source code on this one, but it seems that Android’s layout engine evaluates the TextView’s width based on the text […]

  • Android
  • Named fragment back stack states

    If you’ve been dealing with Android fragments, odds are you’ve used the FragmentTransaction.addToBackStack() method. Often this method is called with a null argument, and that’s fine for most uses. Afterwards, you can pop the top of the back stack by calling FragmentManager.popBackStack() and you’re done. You might be wondering what use is the String parameter […]

  • Android
  • LoanShark 2.0

    A while back I released a new, completely-rewritten version of LoanShark. The current version is 2.0.6 which contains a number of bugfixes, and I consider it to be quite stable. I think writing this version took considerably more effort than the first one, or maybe I have just forgotten how much effort went into the first […]

  • Android
  • Force GC from shell

    To force the garbage collector to run from adb shell, first find out the target process’ id (using e.g. ps), and then execute this in the shell (as root): kill -10 <pid> You should see GC_EXPLICIT in logcat: I/dalvikvm﹕ threadid=3: reacting to signal 10 I/dalvikvm﹕ SIGUSR1 forcing GC (no HPROF) D/dalvikvm﹕ GC_EXPLICIT freed 1K, 9% […]

  • Life
  • First post with my new iPad

    In September last year, I was excited about Samsung’s announcement of the Galaxy Tab 7.7. It had a Super AMOLED HD display at 1280×800 resolution without any of the crappy PenTile matrix faking. As is customary with Samsung, months passed by without the product actually making it onto store shelves. When it finally was available, […]