- android 94
- android studio 16
- quick tips 11
- data binding 9
- lint 9
- eclipse 8
- git 8
- layout 7
- hello 6
- debugging 6
- adb 5
- tools 5
- strings 4
- wtfSDK 3
- XML 3
- EditText 3
- shared preferences 3
- resources 3
- instant apps 3
- formatter 2
- textview 2
- despicable 2
- plurals 2
- shortcut 2
- seekbar 2
- listview 2
- extras 2
- intents 2
- adt 2
- R.java 2
- viewpagerindicator 2
- actionbarsherlock 2
- style 2
- ux 2
- speaking 2
- conference 2
- deeplinks 2
- anti-stress 1
- import project 1
- decimal 1
- hierarchyviewer 1
- autoadjust 1
- maxlines 1
- grammar error 1
- menu 1
- thumboffset 1
- slider 1
- css 1
- font 1
- webview 1
- ScrollView 1
- custom adapter 1
- endless adapter 1
- text color 1
- button 1
- wishful thinking 1
- Google I/O 1
- complex values 1
- the 90s rule 1
- authentication 1
- mongodb 1
- selenium 1
- JUnit 1
- file download 1
- clone 1
- float 1
- submodule 1
- remote branch 1
- logcat 1
- connectivity 1
- notification 1
- utils 1
- gps 1
- location updates 1
- swipe to refresh 1
- database 1
- sqlite 1
- material design 1
- podcast 1
- open source 1
- talks 1
- tech talk 1
- gde 1
- nougat 1
- app links 1
- share 1
- wtm 1
- plaid 1
- io17 1
- arch 1
- quick tip 1
- bye 1
- constraint layout 1
- musings 1
- a11y 1
- accessibility 1
- firebase 1
- crashlytics 1
- parcelize 1
- kotlin 1
- regex 1
android
Lint Revisit: Providing Alternatives 🧙♀️
In my previous post, we updated our TODO Detector to be more flexible. It is also easily extensible so that if we want to include more parameters or perhaps add more checks, we can follow the existing pattern and modify it.
Lint Revisit: TODO Detector v2
A few years ago, I wrote about writing a Lint rule to validate the format of TODO
comments. Whilst I find that
Lint is still difficult to grok, I have since learnt a little bit more that I feel a revisit of this rule is
warranted.
Extended ADB: En Vogue 💃
Last year, I wrote about an extended adb
script. The idea of the script is to make it really easy to issue an adb
command even if there are multiple devices attached by presenting a chooser. For example, if I have two physical devices and an emulator and I want to use my deeplink alias
, I get presented with a device chooser:
➜ ~ deeplink https://zarah.dev
Multiple devices found:
1 - R5CR7039LBJ
2 - 39030FDJH01460
3 - emulator-5554
Select device:
Extending an Interactive ADB 🔀
A few weeks ago, I wrote about a script for making adb
a little bit more interactive. The script makes the process of running an adb
command much smoother if there are multiple devices attached by presenting a chooser. For example, when sending a deeplink:
➜ ~ deeplink https://zarah.dev
Multiple devices found:
1 - R5CR7039LBJ
2 - emulator-5554
3 - emulator-5556
Select device:
Making ADB a little bit dynamic 📱
Android has a lot of tools for developers and one that has been around for as long as I can remember is Android Debug Bridge (adb
). It allows you to issue commands to an attached device, such as installing an app or starting an Activity
.
Bundling Things Nice and Pretty 💝
Of all the projects that I have worked on over the years, one thing they all have in common is the need to pass things around. Whether passing stuff to an Activity
as Intent
extras, a Fragment
as arguments or its onSaveInstanceState
, or even a ViewModel
’s SavedStateHandle
, the most common way to do it is through a Bundle
.
Multi-module Lint Rules Follow Up: Suppressions ☠️
It has been a hot minute since I posted about writing multi-module Lint rules so it’s time for a follow up. Today’s topic: suppressions! A quick recap of where we are:
Debugging App Links in Android 12 🔗
I have been working with deeplinks lately and I noticed that quite a few things have changed since I last worked with them. The most important change is quoted in the list of Android 12 behaviour changes:
Multi-module Lint Rules: Tests 🧪
In my previous post, I talked about how to write a Lint rule that gathers information from different modules before performing a final analysis to determine if there are errors.
Multi-module Lint Rules 🤹♀️
I have been learning a LOT about Lint the past year. Our team has grown 5x since I joined more than three years ago, and it became really obvious really quickly that we should be letting robots do a lot of the mundane and repetitive enforcement of our team’s code conventions.
Accurate Measurements With getTextBounds()
We have a few custom spans in our app and over the last few days I have been poring over one of them. I was trying to see if the implementation could be improved but before that could happen I needed to understand what it was trying to do first.
On-Device Debugging Part V: Strut Your Stuff
Over the past year, my team have been steadily building a Developer Options screen for our app. It is a simple PreferenceScreen
available on debug builds that help us:
- figure out what’s going on without needing to be attached to a computer
- test various configurations without re-installing
- have a host for various experimentations we are trying to explore
On-Device Debugging Part IV: Log All The Things!
Over the past year, my team have been steadily building a Developer Options screen for our app. It is a simple PreferenceScreen
available on debug builds that help us:
- figure out what’s going on without needing to be attached to a computer
- test various configurations without re-installing
- have a host for various experimentations we are trying to explore
On-Device Debugging Part III: Inspect, Reset, Repeat
Over the past year, my team have been steadily building a Developer Options screen for our app. It is a simple PreferenceScreen
available on debug builds that help us:
- figure out what’s going on without needing to be attached to a computer
- test various configurations without re-installing
- have a host for various experimentations we are trying to explore
On-Device Debugging Part II: Timbeeeeeeer!
Over the past year, my team have been steadily building a Developer Options screen for our app. It is a simple PreferenceScreen
available on debug builds that aims to help us:
- figure out what’s going on without needing to be attached to a computer
- test various configurations without re-installing
- have a host for various experimentations we are trying to explore
On-Device Debugging Part I: Now It’s On, Now It’s Off
Over the past year, my team have been steadily building a Developer Options screen for our app. It is a simple PreferenceScreen
available on debug builds that aims to help us:
- figure out what’s going on without needing to be attached to a computer
- test various configurations without re-installing
- have a host for various experimentations we are trying to explore
Tintable Toolbar Things
A few weeks ago, I merged a pull request that updates our app’s theme to Material Components from the Bridge version.
Shortcuts to Shortcuts
It has been a few years since I last looked at implementing app shortcuts, and lately I have been looking at them again. I remember implementing them the first time they were released for Android N, but as with life, things have changed a bit.
Moving On Up (Or Down)
Using CMD+SHIFT+UP/DOWN when reordering element in an enum respects the semicolon. 😍 It's the small things! pic.twitter.com/ct6y537G6a
— Zarah Dominguez 🦉 (@zarahjutz) April 3, 2019
Bug Reports: A Story
“This tool sucks ”
Unwrapping Framework Binding Adapters
For the past year or so, my team has been all-in with data binding. And if you know me at all, it obviously makes me one happy duck!
Okay Google, Show Me a Million Errors
EDIT
Aaaaaaaand an update literally two minutes after I posted this: I was told that the data binding fix made it to the latest Android Studio Canary release.
Ya Basic
Over the last year or so, we have been writing a lot of Kotlin at work. There is a consensus within the team that we all like working with the language. It really helps our productivity a lot by reducing a lot of boilerplate, we can actively enforce nullability rules that makes business logic obvious, and having the option to make extension functions offers a lot of flexibility.
Selectively Resetting SharedPreferences
I have recently been working on a feature that has a bunch of pre-conditions. Things like the user must be logged in AND the feature flag has to be turned on AND it only appears the first time the user lands on the screen.
Effectively Wrangling Together a Bunch of Views
One bit of task that I find myself doing over and over again is managing a bunch of View
s and their visibility. In the olden days <insert old person handwave>, before there was ConstraintLayout
, I have written my fair share of container_
s to make this task manageable. Say we have to do something like this:
Referencing IDs in Data Binding
Last week, I was talking to someone on my team and it became apparent that they weren’t aware of one super useful feature of data binding. If you know me at all, you know that I like love this library, and I would take every opportunity to spread the love around.
Parsing Data Binding Errors
Learning something new is always fun and exciting. That is, until seemingly cryptic error messages start creeping up.
Binding to the H(eight)
As would probably be obvious by now, I have been investing a lot of time in learning and using data binding.
I Like Walls
I have always been told I’m stubborn. And I am. So jumping off this post, I continued doing instant apps stuff and I learnt more things this week.
‘I will just migrate this real quick’, said no one ever
When Android Studio 3.0 was announced at I/O, I was very keen to try it out. Mostly because of all the cool stuff in it, but also because of more support for instant apps.
Children, Respect Your Parent(s)
I was updating a bit of code the other day that involved dynamically inflating views into a LinearLayout
using DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.row_related_property, container, false)
.
Making the Domain Android App Instant ⚡
The couple of months before I/O had been pretty hectic. Super excited to be able to finally talk about it!
There is Always Room for Improvement
During the beginning of my Android career, one of the things I had to do was to save some data to somewhere. I found out that for my purposes, I had to use an SQLite database. Reading through the docs, I was afraid. Petrified, even.
@{app.plaid}
I gave a talk this morning in the first ever Droidcon Vietnam! It is about two of the things I love in Android – Plaid and data binding.
Sharing is Caring
Or so they say.
I just spent an hour debugging an issue that should have been a non-issue at all.
Troubleshooting autoVerify
So you implement app links and you are 300% sure you have implemented everything correctly. The important thing to remember here is that verification is all or nothing. From the docs:
The Quirks of Supporting SDK 25
The last developer preview of Android 7.1 has started shipping, which means APIs are (based on past experience) more or less stable. There is a very good write up on developer.android.com on how to get started with supporting these new features. I set about trying it out, and here’s what happened.
A Little UX Love Goes A Long Way
Yesterday, my bank pushed a notification asking if I’m going to travel. Yes! I am! I filled up the form they asked me to fill up, and tapped Submit.
Tools of the Trade: Unabridged
I gave an unabridged version of my last Android Meetup talk at this year’s YOW Conference. It has been an honour being part of this awesome conference!
String formatting and Lint
One piece of advice that we keep hearing over and over is to extract strings into resources. There really is no reason for you to hard code strings in code.
Pidcat <3 Android M
If you use Pidcat, there might be issues running the tool if your device is on M+. The issue has been fixed on master but hasn’t been released yet.
A big step
Today was the day.
Stylish Dynamic Layouts
One of the things we are taught in Android is that we should gracefully handle different layouts based on screen sizes. With more and more things being not just screen size-specific but also OS version-specific, this is one thing I think a lot more devs need to pay attention to. Today was my turn to do just that.
Using resource IDs in data binding layouts
I have been playing with data binding more and more over the last couple of weeks. This week, it’s all about creating a dialog with stuff dictated by a value from an enum.
Quick tip: Enabling data binding
Say you have a simple layout file:
In which I was in a podcast
It has been a month since IO and in case you missed it, I got to chat with Kaushik of Fragmented. And by golly, I made it into an episode! At that point I was about to lose my voice, so I sound really husky. :p
More Watches Love and a note on Context
I have previously written about debugging and how Watches can help make inspecting things in your code easier. Today, I would like to reiterate how powerful Watches can be.
Taking a closer look while debugging
One of the most common sources of bugs (at least of my bugs) is math. I have been working on dynamically resizing a View the past days, and it was driving me nuts! I needed to consider preserving aspect ratio, device density, original view size, etc etc. Math is hard guys!
LinearLayouts, TextViews and Drawables
I sent out a series of tweets today about LinearLayout
s and unexpectedly, quite a few people like them. I decided to get off my lazy ass and actually write it down in a post for easy reference.
Squashing Bugs
This has been one hell of a busy week for me. I think you can sort of tell from my Tweets and G+ posts that I have been debugging A LOT.
Annotating all (or most of) the things
If, like me, you are old and have been developing for Android for a while, you should, like me, appreciate the fact that the backwards compatibility of the OS has come a long way. Sure, they may toy with my feelings from time to time, but we all need a little excitement every now and then.
NOT another day at the office
We had another round of Innovation Day at Domain last month, and I wrote about it. We started out dreaming up this ambitious project – too ambitious for two days! Here’s a partial list of what we had to do:
- Build a wall
- Stick devices on said wall
- Make app that cycles through photos from listings
- Load said app on those devices that we stuck to the wall
- Figure out how to track people who get devices
- What if someone just gets a device?!
- Figure out how to let people give back devices
- Oh! oh! oh! Wouldn’t it be cool if other devices cheer when one of them “comes home”?
- How do we put new versions of the app on those devices?
- Run tests, maybe?
- What if the website team wants to test responsive designs?
- Do they even charge????!!!
Raising Activities From the Dead
One of the scenarios I admittedly ~almost~ always forget to test is “What happens when my app goes into the background, then the OS kills is to claim memory, then I try to resume?” Usually it’s “Well, I handle onSavedInstanceState
not being null
, so I am great!” It is fine and dandy for simple apps; but once your Activity
or Fragment
gets beefier and you start relying on state for more and more things, it can get complicated pretty quickly (In my case, the Fragment
has setRetainInstance(true)
).
Stringy strings
While we are on the subject of strings, here are more ways of dealing with them in Android Studio. We all know that we should not hardcode strings in code, right? But sometimes, we forget and tend to do code first before defining them in strings.xml
.
On being material
In case you missed it, I made a blog post about updating our app to material design. In it I talk about what material design is and what we did to adopt it. I hope you enjoy reading it as much as I did writing it. :) Head on over to Domain’s tech blog for the details.
SQLiteAssetHelper + ORMLite
I recently had cause to use Jeff Gilfelt’s SQLite Asset Helper library. For those unfamiliar, it is a library that can help with including a pre-populated SQLite database with your Android application. It is extremely convenient with unbundling a potentially huge database you would want to ship.
AutoCompleteTextView Hell
Today, I ran into a weird “feature” of Android. I was working on an AutoCompleteTextView with the dropdown list having section dividers. It all works well in portrait mode, but gets all messed up in landscape.
Swipe, not Pull, to Refresh
I have recently came across this new View in the support library package that allows your app to have built-in support for pull swipe to refresh. This is pretty cool, since we don’t have to use any of the libraries out there. Admittedly, very little customization can be done, but then what else can we customize, right?
Quick Tip: Understanding Alternate Resources
Trying to support as many devices as possible the best way possible is a very daunting task indeed. You will usually need to provide a lot of different layouts, strings, or dimensions (among others) to make your app look great whatever the user’s device is. And then you start chaining resource qualifiers and testing which resource is being loaded by the OS can become a nightmare very quickly.
Adding attributes to a custom view
There are times when using the default Android Views just doesn’t cut it and you need to create your own version of a View. So how exactly do you do that? It’s as simple as subclassing the View! But what if you want to add customizable attributes? Here’s how.
Quick Tip: Updating the location update frequency
When using Google Play’s Location Services and you want to change the frequency of the updates, make sure to do these in order:
Setting up the SeekBar
So we want to use the SeekBar
. We want the minimum value to be 10 and the maximum value to be 100, and it should increment by 10.
Quick Tip: Checking for emptiness
Always using if(myString != null && myString.length() > 0)
? Use !TextUtils.isEmpty(myString)
instead.
Quick Tip: Pulling an SQLite db file from device
I have always thought that you would need root access to pull an SQLite file from a non-rooted Android device. Turns out I thought wrong! Here’s how you do it:
$ adb -d shell
$ run-as your.package.name
$ cat /data/data/your.package.name/databases/yourdatabasename >/sdcard/yourdatabasename
I Can Haz Internetz!
Last week, I was exploring connectivity monitoring and came up with a small app for demo. The app listens for connectivity changes and sends a notification to the user informing them of the change.
Making ActionBarSherlock and ViewPagerIndicator play nice
EDIT (20121227): I made a new post on changing the tab selector underline.
EDIT (20121014): I received feedback from the comments that rotating the device will cause the tab contents to revert to the default text. In essence, the adapter “loses” the contents of the tabs. I have corrected this in the example below as well as in github.
EDIT (20120905): The full sample source code is now in github.
Save Logcat contents to file
Note to self: to save the contents of Logcat to a text file:
Cloning a remote branch in git
My current project at work uses git, and I have always been a CVS/SVN baby so I’m still trying to find my way around it. Today I wanted to clone a remote branch to my local computer. This remote branch also has submodules, so I want to get those too.
Adding Preferences On-The-Fly
(Make appropriate whooshing sounds)
Inspecting your Shared Preferences
Did you know that you can look at your SharedPreferences file?
Adding a float value to your resources
Earlier today, I was trying to figure out how to add a float value to constants file. What I used to do was add a string value in my strings.xml
, retrieve the string value, and convert it to float.
float floatFromFile = Float.valueOf(getResources().getString(R.string.my_float));
Where’s my R.java?
This afternoon, I tried importing an existing project into Eclipse. Doing a Project > Clean usually clears up the R.java not found errors, but this time it didn’t work. I tried re-importing the project, copy-and-pasting it into a new workspace, restarting Eclipse, but the error is still there.
ADT 12: Not so shiny after all
Passing complex objects to another Activity
Several months ago, I was faced with a problem of passing a complex object to another Activity. There are several ways of doing this:
- “Deconstructing” the complex object to simple data types and passing them as extras through
putExtra()
- Making the object
Parcelable
- Making the object
Serializable
Dreaming of Google I/O: ADT preview
It is my dream to one day attend Google I/O. But seeing as I’m from a Third World country where everyday is a practice in cost-cutting, it is very unlikely that I would fulfill that dream anytime soon. I haven’t sat down and computed the actual cost, but thinking about it makes my head spin. Off the top of my head:
- US Visa application = P6500 (~USD150)
- Round trip plane fare ticket = P90,000 (~USD2000, if I’m lucky)-
- Google I/O ticket = P21,000 (~USD450, if my research is correct)
Changing a button’s text color
There are times that when changing a button’s background color, we also want to change the text’s color. There is a method setTextColor(int color)
specifically for this purpose. Seems pretty straightforward enough, but it took me a few tries to get it right the first time I tried using it. Documenting it here so that I wouldn’t forget.
Using CWAC’s EndlessAdapter with a custom adapter
In one of my projects, the app has the potential to display a very, and I mean very, long list. To minimize the loading time of the app, I limit the number of items initially included in the list and then add to it as the user scrolls down.
My EditText is cut off by the on-screen keyboard!
With clients demanding left and right that my app should look like an iPhone app, I tend to be unappreciative of the way Android natively handles UI interactions and such. Notice how the screen automagically scrolls up when you click on an EditText
? It turns out that in iPhone development, the developer does this manually (indicate how much the view should scroll when the on-screen keyboard appears, then scroll it back down afterwards). HA!
Using a custom font in WebView
In one of my projects, I needed to display some special characters that the Android OS by itself cannot seem to render. I figured that I would need to provide a custom font that includes the characters that I needed.
It never ends!
Been ultra super busy the past few weeks. Also learning a lot of new things. And renewing my battle with orientation change, AsyncTasks and dialog boxes.
stealth ninja mode on
Over the past couple of weeks, this blog has been getting unusually high traffic. Which means I get more than one hit per week.
That damn seekbar thumb
If you have ever needed to use a SeekBar
, you definitely would have noticed how hard it is to move the slider (aka thumb) when it is set to the minimum or maximum value. The slider tends to be cut in half, and fitting your finger into it to press it becomes a test of patience.
Enabling/disabling menu items on the fly
In one of my applications, I want to disable some menu entries if the database is not valid or is not present at all. To do that, I make use of the onPrepareOptionsMenu
() API.
Quick tip: Quick Formatting of Android XML Files
One of the most useful tools in Android’s Eclipse plug-in is the Layout Editor. It is easy to experiment with layouts using the drag-and-drop enabled editor without having to worry about the correct syntax or if you are using the correct attribute name.
What happened to my layout editor?
There you are, happily creating your layout files in the Eclipse plug-in’s layout editor. Dragging and dropping is a breeze. But then one day, you open a layout XML file and boom! No UI! All you see is the XML tree with all the nodes and attributes. What happened?
What grammar?
My OC side was alarmed when suddenly, my Problems view in Eclipse was filled with warnings on my XML files. Each of my XML files had a warning with it, and that little yellow exclamation mark on the side:
TextView and MaxLines
I have a TextView (who doesn’t?) and I want to adjust its height automatically, depending on the length of the text it will contain. Should be easy. It was, but it took me a couple of minutes to figure it out.
Missing hierarchyviewer in SDK 7
If you have SDK version 7, you are most probably missing the hierarchyviewer
from your /tools
folder. To check your SDK version, launch the SDK manager UI from your installation path, usually C:\android-sdk-windows
, then click About.
More plurals: decimal values
In my previous post, I showed you how to set string plurals. If you noticed, the methods to get the plurals strings only accept int
s. What if (like me) you want to display a decimal value? I am getting my raw value from a progress bar with a range of 1-10, with 0.1 increments.
String Pluralization
Last week, I discovered Android’s support for plural strings by accident. And a good accident it was since I am working on an app that will display a float to the user. I used to display:
Importing existing Android projects to Eclipse
When trying to import an existing Android project to Eclipse, I always encounter the error: The method *XXXXX* must override a superclass method
.
Quick string resource formatting
Sooner or later, you would want to display a message to your user with dynamic content. This may be the number of results, the user’s name, etc.
A test, a test
I was thinking of starting a quick-tips style blog for software development (mostly for myself, since I tend to forget stuff a lot recently).
android studio
XML Parsing in Lint: Things Are Not What They Seem 🦹♀️
About a year ago, I wrote about including quickfixes for Lint rules. Quick fixes appear on the context menu when Lint flags an error and allows developers to quickly address the issue. They can be applied by clicking on the link at the bottom of the dialog or pressing ALT+ENTER (⌥ + ↩) and then choosing the fix.
Enforcing Team Rules with Lint: Tests 🧐
A few months ago, my team came upon an agreement that when leaving a TODO anywhere in our code, we need to always provide several things:
- the person who is expected to address the TODO
- date when the TODO was left
- a comment or explanation on what needs to be done
Enforcing Team Rules with Lint: Detectors 🕵️
A few months ago, my team came upon an agreement that when leaving a TODO anywhere in our code, we need to always provide several things:
- the person who is expected to address the TODO
- date when the TODO was left
- a comment or explanation on what needs to be done
Enforcing Team Rules with Lint 👩🔧
A few months ago, my team came upon an agreement that when leaving a TODO anywhere in our code, we need to always provide several things:
- the person who is expected to address the TODO
- date when the TODO was left
- a comment or explanation on what needs to be done
Easy Navigation with Bookmarks
One of the things I find most challenging when learning a new part of a codebase is navigating through the data flow. In some areas of our app, following RX streams can be particularly… draining.
//TODO Live Templates
Throughout my career, I have worked in projects of all sizes. I have taken part in greenfield projects and some that are a few years old. One of the lessons I have learned over the years is that no one ever goes back to fix the TODO
s.
Which is Which: Named Breakpoints
I have always believed that one of the biggest factors that influence a person’s enjoyment and delight in doing their job are the tools. Having the right tools and using them the best way possible helps direct our energy on the what rather than the how.
Scratch That Itch
One of the most useful things for me whilst I was learning Kotlin was TryKotlin. It gave me a quick way to test concepts, try new APIs, or just to get familiar with the syntax.
Tools of the Trade: Unabridged
I gave an unabridged version of my last Android Meetup talk at this year’s YOW Conference. It has been an honour being part of this awesome conference!
Snazzy git blaming
Sometimes, you can’t help it. You need to look at what happened in the past to understand what is happening in the present (wow).
Squashing Bugs
This has been one hell of a busy week for me. I think you can sort of tell from my Tweets and G+ posts that I have been debugging A LOT.
Raising Activities From the Dead
One of the scenarios I admittedly ~almost~ always forget to test is “What happens when my app goes into the background, then the OS kills is to claim memory, then I try to resume?” Usually it’s “Well, I handle onSavedInstanceState
not being null
, so I am great!” It is fine and dandy for simple apps; but once your Activity
or Fragment
gets beefier and you start relying on state for more and more things, it can get complicated pretty quickly (In my case, the Fragment
has setRetainInstance(true)
).
Lies I’ve been told today
So I played around with data binding today. And these are the lies that the dev guide told me (explicitly or inferred):
- There is a method `DataBindingUtil.bindTo(viewRoot, layoutId)
- That this will work
MyLayoutBinding.bind(viewRoot);
- Android Studio has auto-complete
Pasting and Extracting Stuff
A lot of times, but especially when I am implementing some new logic, coding for me takes several steps:
- Write down what I have to do as comments
- Implement what I have written down
- Refactor and improve what I have implemented
Super lightning talk: Tinkering with Tools
If you are just starting Android development or migrating from Eclipse to Android Studio, I gave a lightning talk on setting up some tools:
Stringy strings
While we are on the subject of strings, here are more ways of dealing with them in Android Studio. We all know that we should not hardcode strings in code, right? But sometimes, we forget and tend to do code first before defining them in strings.xml
.
quick tips
I just spent an hour debugging an issue that should have been a non-issue at all.
Troubleshooting autoVerify
So you implement app links and you are 300% sure you have implemented everything correctly. The important thing to remember here is that verification is all or nothing. From the docs:
Quick tip: Enabling data binding
Say you have a simple layout file:
Stringy strings
While we are on the subject of strings, here are more ways of dealing with them in Android Studio. We all know that we should not hardcode strings in code, right? But sometimes, we forget and tend to do code first before defining them in strings.xml
.
Quick Tip: Understanding Alternate Resources
Trying to support as many devices as possible the best way possible is a very daunting task indeed. You will usually need to provide a lot of different layouts, strings, or dimensions (among others) to make your app look great whatever the user’s device is. And then you start chaining resource qualifiers and testing which resource is being loaded by the OS can become a nightmare very quickly.
Quick Tip: Updating the location update frequency
When using Google Play’s Location Services and you want to change the frequency of the updates, make sure to do these in order:
Quick Tip: Checking for emptiness
Always using if(myString != null && myString.length() > 0)
? Use !TextUtils.isEmpty(myString)
instead.
Quick Tip: Pulling an SQLite db file from device
I have always thought that you would need root access to pull an SQLite file from a non-rooted Android device. Turns out I thought wrong! Here’s how you do it:
$ adb -d shell
$ run-as your.package.name
$ cat /data/data/your.package.name/databases/yourdatabasename >/sdcard/yourdatabasename
Save Logcat contents to file
Note to self: to save the contents of Logcat to a text file:
Adding a float value to your resources
Earlier today, I was trying to figure out how to add a float value to constants file. What I used to do was add a string value in my strings.xml
, retrieve the string value, and convert it to float.
float floatFromFile = Float.valueOf(getResources().getString(R.string.my_float));
Quick Tip: git cloning
A user-friendly way of cloning a git
repo is through the eGit plug-in in Eclipse. But sometimes, especially on Windows machines, Eclipse has trouble cleaning up after itself after completing a clone operation. The best workaround for this is to clone the repo from git bash
and then import the repo in Eclipse.
default@ZDOMINGUEZ-T420 ~
$ git clone git@github.com:<your git repo> <local folder to check out to>
data binding
Unwrapping Framework Binding Adapters
For the past year or so, my team has been all-in with data binding. And if you know me at all, it obviously makes me one happy duck!
Effectively Wrangling Together a Bunch of Views
One bit of task that I find myself doing over and over again is managing a bunch of View
s and their visibility. In the olden days <insert old person handwave>, before there was ConstraintLayout
, I have written my fair share of container_
s to make this task manageable. Say we have to do something like this:
Referencing IDs in Data Binding
Last week, I was talking to someone on my team and it became apparent that they weren’t aware of one super useful feature of data binding. If you know me at all, you know that I like love this library, and I would take every opportunity to spread the love around.
Parsing Data Binding Errors
Learning something new is always fun and exciting. That is, until seemingly cryptic error messages start creeping up.
Binding to the H(eight)
As would probably be obvious by now, I have been investing a lot of time in learning and using data binding.
@{app.plaid}
I gave a talk this morning in the first ever Droidcon Vietnam! It is about two of the things I love in Android – Plaid and data binding.
Using resource IDs in data binding layouts
I have been playing with data binding more and more over the last couple of weeks. This week, it’s all about creating a dialog with stuff dictated by a value from an enum.
Quick tip: Enabling data binding
Say you have a simple layout file:
Lies I’ve been told today
So I played around with data binding today. And these are the lies that the dev guide told me (explicitly or inferred):
- There is a method `DataBindingUtil.bindTo(viewRoot, layoutId)
- That this will work
MyLayoutBinding.bind(viewRoot);
- Android Studio has auto-complete
lint
Lint Revisit: Providing Alternatives 🧙♀️
In my previous post, we updated our TODO Detector to be more flexible. It is also easily extensible so that if we want to include more parameters or perhaps add more checks, we can follow the existing pattern and modify it.
Lint Revisit: TODO Detector v2
A few years ago, I wrote about writing a Lint rule to validate the format of TODO
comments. Whilst I find that
Lint is still difficult to grok, I have since learnt a little bit more that I feel a revisit of this rule is
warranted.
Multi-module Lint Rules Follow Up: Suppressions ☠️
It has been a hot minute since I posted about writing multi-module Lint rules so it’s time for a follow up. Today’s topic: suppressions! A quick recap of where we are:
XML Parsing in Lint: Things Are Not What They Seem 🦹♀️
About a year ago, I wrote about including quickfixes for Lint rules. Quick fixes appear on the context menu when Lint flags an error and allows developers to quickly address the issue. They can be applied by clicking on the link at the bottom of the dialog or pressing ALT+ENTER (⌥ + ↩) and then choosing the fix.
Multi-module Lint Rules: Tests 🧪
In my previous post, I talked about how to write a Lint rule that gathers information from different modules before performing a final analysis to determine if there are errors.
Multi-module Lint Rules 🤹♀️
I have been learning a LOT about Lint the past year. Our team has grown 5x since I joined more than three years ago, and it became really obvious really quickly that we should be letting robots do a lot of the mundane and repetitive enforcement of our team’s code conventions.
Enforcing Team Rules with Lint: Tests 🧐
A few months ago, my team came upon an agreement that when leaving a TODO anywhere in our code, we need to always provide several things:
- the person who is expected to address the TODO
- date when the TODO was left
- a comment or explanation on what needs to be done
Enforcing Team Rules with Lint: Detectors 🕵️
A few months ago, my team came upon an agreement that when leaving a TODO anywhere in our code, we need to always provide several things:
- the person who is expected to address the TODO
- date when the TODO was left
- a comment or explanation on what needs to be done
Enforcing Team Rules with Lint 👩🔧
A few months ago, my team came upon an agreement that when leaving a TODO anywhere in our code, we need to always provide several things:
- the person who is expected to address the TODO
- date when the TODO was left
- a comment or explanation on what needs to be done
eclipse
Eclipse-ception
Guys!! Eclipse just went all Inception on me!
Quick Tip: git cloning
A user-friendly way of cloning a git
repo is through the eGit plug-in in Eclipse. But sometimes, especially on Windows machines, Eclipse has trouble cleaning up after itself after completing a clone operation. The best workaround for this is to clone the repo from git bash
and then import the repo in Eclipse.
default@ZDOMINGUEZ-T420 ~
$ git clone git@github.com:<your git repo> <local folder to check out to>
Where’s my R.java?
This afternoon, I tried importing an existing project into Eclipse. Doing a Project > Clean usually clears up the R.java not found errors, but this time it didn’t work. I tried re-importing the project, copy-and-pasting it into a new workspace, restarting Eclipse, but the error is still there.
ADT 12: Not so shiny after all
Quick tip: Quick Formatting of Android XML Files
One of the most useful tools in Android’s Eclipse plug-in is the Layout Editor. It is easy to experiment with layouts using the drag-and-drop enabled editor without having to worry about the correct syntax or if you are using the correct attribute name.
What happened to my layout editor?
There you are, happily creating your layout files in the Eclipse plug-in’s layout editor. Dragging and dropping is a breeze. But then one day, you open a layout XML file and boom! No UI! All you see is the XML tree with all the nodes and attributes. What happened?
What grammar?
My OC side was alarmed when suddenly, my Problems view in Eclipse was filled with warnings on my XML files. Each of my XML files had a warning with it, and that little yellow exclamation mark on the side:
Importing existing Android projects to Eclipse
When trying to import an existing Android project to Eclipse, I always encounter the error: The method *XXXXX* must override a superclass method
.
git
Lazy dev: Indexed Branch Switching 🌳
Back in August, I wrote about making an alias for finding the five most recent branches I have checked out by filtering out git reflog
entries.
Harnessing the Power of Reflogs 🧙♀️
A few weeks ago, I tweeted about a discovery that blew my mind:
That Thing About Commit Messages
Last week, I was giving feedback to someone about improving the commit messages they write. I was very taken aback by their response – “it does not matter what the commit messages are”. Now this is confusing for me, mainly because I know from years of experience that having relevant commit messages is important.
Snazzy git blaming
Sometimes, you can’t help it. You need to look at what happened in the past to understand what is happening in the present (wow).
Fixing a mistake in your git history
I have been using git for about five years now, but I definitely get stumped by it a lot. It is so powerful it’s daunting. There has been a couple lot of times where I had been too careless and reliant on my fingers’ add-commit-push muscle memory that I realised I have made a mistake too late. I have always been a proponent of clean, atomic commits, and when I find my commits all messed up, I hit myself in the head.
Quick Tip: git Auto-complete
When I started using git, it peeved me that there is no auto-complete. More so when you have to manually do a git add
manually.
Cloning a remote branch in git
My current project at work uses git, and I have always been a CVS/SVN baby so I’m still trying to find my way around it. Today I wanted to clone a remote branch to my local computer. This remote branch also has submodules, so I want to get those too.
Quick Tip: git cloning
A user-friendly way of cloning a git
repo is through the eGit plug-in in Eclipse. But sometimes, especially on Windows machines, Eclipse has trouble cleaning up after itself after completing a clone operation. The best workaround for this is to clone the repo from git bash
and then import the repo in Eclipse.
default@ZDOMINGUEZ-T420 ~
$ git clone git@github.com:<your git repo> <local folder to check out to>
layout
Stylish Dynamic Layouts
One of the things we are taught in Android is that we should gracefully handle different layouts based on screen sizes. With more and more things being not just screen size-specific but also OS version-specific, this is one thing I think a lot more devs need to pay attention to. Today was my turn to do just that.
LinearLayouts, TextViews and Drawables
I sent out a series of tweets today about LinearLayout
s and unexpectedly, quite a few people like them. I decided to get off my lazy ass and actually write it down in a post for easy reference.
Quick Tip: Understanding Alternate Resources
Trying to support as many devices as possible the best way possible is a very daunting task indeed. You will usually need to provide a lot of different layouts, strings, or dimensions (among others) to make your app look great whatever the user’s device is. And then you start chaining resource qualifiers and testing which resource is being loaded by the OS can become a nightmare very quickly.
Adding attributes to a custom view
There are times when using the default Android Views just doesn’t cut it and you need to create your own version of a View. So how exactly do you do that? It’s as simple as subclassing the View! But what if you want to add customizable attributes? Here’s how.
Styling tab selectors for ActionBarSherlock
This post builds on the previous post for ABS + VPI.
My EditText is cut off by the on-screen keyboard!
With clients demanding left and right that my app should look like an iPhone app, I tend to be unappreciative of the way Android natively handles UI interactions and such. Notice how the screen automagically scrolls up when you click on an EditText
? It turns out that in iPhone development, the developer does this manually (indicate how much the view should scroll when the on-screen keyboard appears, then scroll it back down afterwards). HA!
What happened to my layout editor?
There you are, happily creating your layout files in the Eclipse plug-in’s layout editor. Dragging and dropping is a breeze. But then one day, you open a layout XML file and boom! No UI! All you see is the XML tree with all the nodes and attributes. What happened?
hello
2017: The year in review
Welp. Here we are. Another year is about to end.
A note on giving back
Recently, there has been a spate of tweets about developers admitting their weaknesses. A bunch of people I know even made into the Moment created by @ThePracticalDev. And then there’s this tweet:
Winging It: How I Got to be an Android Dev And What I Learned From It
They say all relationships go through a rough patch at two, seven, then ten years. I don’t remember who said it, but someone told me that many years ago.
Hello, it’s me again.
To my two readers out there, hello! It’s been a while since I posted here. I was transferred to another (non-Android) project and lost all my Internet privileges, hence the silence. I still can’t believe almost every other site is blocked by the office firewall! Makes software development ten times harder. Ugh.
stealth ninja mode on
Over the past couple of weeks, this blog has been getting unusually high traffic. Which means I get more than one hit per week.
A test, a test
I was thinking of starting a quick-tips style blog for software development (mostly for myself, since I tend to forget stuff a lot recently).
debugging
More Watches Love and a note on Context
I have previously written about debugging and how Watches can help make inspecting things in your code easier. Today, I would like to reiterate how powerful Watches can be.
Taking a closer look while debugging
One of the most common sources of bugs (at least of my bugs) is math. I have been working on dynamically resizing a View the past days, and it was driving me nuts! I needed to consider preserving aspect ratio, device density, original view size, etc etc. Math is hard guys!
Squashing Bugs
This has been one hell of a busy week for me. I think you can sort of tell from my Tweets and G+ posts that I have been debugging A LOT.
Raising Activities From the Dead
One of the scenarios I admittedly ~almost~ always forget to test is “What happens when my app goes into the background, then the OS kills is to claim memory, then I try to resume?” Usually it’s “Well, I handle onSavedInstanceState
not being null
, so I am great!” It is fine and dandy for simple apps; but once your Activity
or Fragment
gets beefier and you start relying on state for more and more things, it can get complicated pretty quickly (In my case, the Fragment
has setRetainInstance(true)
).
Quick Tip: Pulling an SQLite db file from device
I have always thought that you would need root access to pull an SQLite file from a non-rooted Android device. Turns out I thought wrong! Here’s how you do it:
$ adb -d shell
$ run-as your.package.name
$ cat /data/data/your.package.name/databases/yourdatabasename >/sdcard/yourdatabasename
Inspecting your Shared Preferences
Did you know that you can look at your SharedPreferences file?
adb
Extended ADB: En Vogue 💃
Last year, I wrote about an extended adb
script. The idea of the script is to make it really easy to issue an adb
command even if there are multiple devices attached by presenting a chooser. For example, if I have two physical devices and an emulator and I want to use my deeplink alias
, I get presented with a device chooser:
➜ ~ deeplink https://zarah.dev
Multiple devices found:
1 - R5CR7039LBJ
2 - 39030FDJH01460
3 - emulator-5554
Select device:
Extending an Interactive ADB 🔀
A few weeks ago, I wrote about a script for making adb
a little bit more interactive. The script makes the process of running an adb
command much smoother if there are multiple devices attached by presenting a chooser. For example, when sending a deeplink:
➜ ~ deeplink https://zarah.dev
Multiple devices found:
1 - R5CR7039LBJ
2 - emulator-5554
3 - emulator-5556
Select device:
Making ADB a little bit dynamic 📱
Android has a lot of tools for developers and one that has been around for as long as I can remember is Android Debug Bridge (adb
). It allows you to issue commands to an attached device, such as installing an app or starting an Activity
.
Tools of the Trade: Unabridged
I gave an unabridged version of my last Android Meetup talk at this year’s YOW Conference. It has been an honour being part of this awesome conference!
Save Logcat contents to file
Note to self: to save the contents of Logcat to a text file:
tools
Which is Which: Named Breakpoints
I have always believed that one of the biggest factors that influence a person’s enjoyment and delight in doing their job are the tools. Having the right tools and using them the best way possible helps direct our energy on the what rather than the how.
Scratch That Itch
One of the most useful things for me whilst I was learning Kotlin was TryKotlin. It gave me a quick way to test concepts, try new APIs, or just to get familiar with the syntax.
Tools of the Trade
Here are the slides to my talk at the Android Meetup tonight.
Pidcat <3 Android M
If you use Pidcat, there might be issues running the tool if your device is on M+. The issue has been fixed on master but hasn’t been released yet.
Super lightning talk: Tinkering with Tools
If you are just starting Android development or migrating from Eclipse to Android Studio, I gave a lightning talk on setting up some tools:
strings
String formatting and Lint
One piece of advice that we keep hearing over and over is to extract strings into resources. There really is no reason for you to hard code strings in code.
Stringy strings
While we are on the subject of strings, here are more ways of dealing with them in Android Studio. We all know that we should not hardcode strings in code, right? But sometimes, we forget and tend to do code first before defining them in strings.xml
.
More plurals: decimal values
In my previous post, I showed you how to set string plurals. If you noticed, the methods to get the plurals strings only accept int
s. What if (like me) you want to display a decimal value? I am getting my raw value from a progress bar with a range of 1-10, with 0.1 increments.
String Pluralization
Last week, I discovered Android’s support for plural strings by accident. And a good accident it was since I am working on an app that will display a float to the user. I used to display:
wtfSDK
Eclipse-ception
Guys!! Eclipse just went all Inception on me!
ADT 12: Not so shiny after all
Missing hierarchyviewer in SDK 7
If you have SDK version 7, you are most probably missing the hierarchyviewer
from your /tools
folder. To check your SDK version, launch the SDK manager UI from your installation path, usually C:\android-sdk-windows
, then click About.
XML
Quick tip: Quick Formatting of Android XML Files
One of the most useful tools in Android’s Eclipse plug-in is the Layout Editor. It is easy to experiment with layouts using the drag-and-drop enabled editor without having to worry about the correct syntax or if you are using the correct attribute name.
What happened to my layout editor?
There you are, happily creating your layout files in the Eclipse plug-in’s layout editor. Dragging and dropping is a breeze. But then one day, you open a layout XML file and boom! No UI! All you see is the XML tree with all the nodes and attributes. What happened?
What grammar?
My OC side was alarmed when suddenly, my Problems view in Eclipse was filled with warnings on my XML files. Each of my XML files had a warning with it, and that little yellow exclamation mark on the side:
EditText
AutoCompleteTextView Hell
Today, I ran into a weird “feature” of Android. I was working on an AutoCompleteTextView with the dropdown list having section dividers. It all works well in portrait mode, but gets all messed up in landscape.
Adding attributes to a custom view
There are times when using the default Android Views just doesn’t cut it and you need to create your own version of a View. So how exactly do you do that? It’s as simple as subclassing the View! But what if you want to add customizable attributes? Here’s how.
My EditText is cut off by the on-screen keyboard!
With clients demanding left and right that my app should look like an iPhone app, I tend to be unappreciative of the way Android natively handles UI interactions and such. Notice how the screen automagically scrolls up when you click on an EditText
? It turns out that in iPhone development, the developer does this manually (indicate how much the view should scroll when the on-screen keyboard appears, then scroll it back down afterwards). HA!
resources
A big step
Today was the day.
Using resource IDs in data binding layouts
I have been playing with data binding more and more over the last couple of weeks. This week, it’s all about creating a dialog with stuff dictated by a value from an enum.
Quick Tip: Understanding Alternate Resources
Trying to support as many devices as possible the best way possible is a very daunting task indeed. You will usually need to provide a lot of different layouts, strings, or dimensions (among others) to make your app look great whatever the user’s device is. And then you start chaining resource qualifiers and testing which resource is being loaded by the OS can become a nightmare very quickly.
instant apps
I Like Walls
I have always been told I’m stubborn. And I am. So jumping off this post, I continued doing instant apps stuff and I learnt more things this week.
‘I will just migrate this real quick’, said no one ever
When Android Studio 3.0 was announced at I/O, I was very keen to try it out. Mostly because of all the cool stuff in it, but also because of more support for instant apps.
Making the Domain Android App Instant ⚡
The couple of months before I/O had been pretty hectic. Super excited to be able to finally talk about it!
formatter
Using a custom font in WebView
In one of my projects, I needed to display some special characters that the Android OS by itself cannot seem to render. I figured that I would need to provide a custom font that includes the characters that I needed.
Quick string resource formatting
Sooner or later, you would want to display a message to your user with dynamic content. This may be the number of results, the user’s name, etc.
textview
TextView and MaxLines
I have a TextView (who doesn’t?) and I want to adjust its height automatically, depending on the length of the text it will contain. Should be easy. It was, but it took me a couple of minutes to figure it out.
Quick string resource formatting
Sooner or later, you would want to display a message to your user with dynamic content. This may be the number of results, the user’s name, etc.
despicable
It never ends!
Been ultra super busy the past few weeks. Also learning a lot of new things. And renewing my battle with orientation change, AsyncTasks and dialog boxes.
It’s so fluffyyyyyyyyy!!!
<img src=http://www.despicable.me/pops/minionMaker/userpics/910156207.jpg width=”380” height=”473” alt=”I’ve created a Minion to join Gru’s Minion army.” />
plurals
More plurals: decimal values
In my previous post, I showed you how to set string plurals. If you noticed, the methods to get the plurals strings only accept int
s. What if (like me) you want to display a decimal value? I am getting my raw value from a progress bar with a range of 1-10, with 0.1 increments.
String Pluralization
Last week, I discovered Android’s support for plural strings by accident. And a good accident it was since I am working on an app that will display a float to the user. I used to display:
shortcut
Pasting and Extracting Stuff
A lot of times, but especially when I am implementing some new logic, coding for me takes several steps:
- Write down what I have to do as comments
- Implement what I have written down
- Refactor and improve what I have implemented
Quick tip: Quick Formatting of Android XML Files
One of the most useful tools in Android’s Eclipse plug-in is the Layout Editor. It is easy to experiment with layouts using the drag-and-drop enabled editor without having to worry about the correct syntax or if you are using the correct attribute name.
seekbar
Setting up the SeekBar
So we want to use the SeekBar
. We want the minimum value to be 10 and the maximum value to be 100, and it should increment by 10.
That damn seekbar thumb
If you have ever needed to use a SeekBar
, you definitely would have noticed how hard it is to move the slider (aka thumb) when it is set to the minimum or maximum value. The slider tends to be cut in half, and fitting your finger into it to press it becomes a test of patience.
listview
Swipe, not Pull, to Refresh
I have recently came across this new View in the support library package that allows your app to have built-in support for pull swipe to refresh. This is pretty cool, since we don’t have to use any of the libraries out there. Admittedly, very little customization can be done, but then what else can we customize, right?
Using CWAC’s EndlessAdapter with a custom adapter
In one of my projects, the app has the potential to display a very, and I mean very, long list. To minimize the loading time of the app, I limit the number of items initially included in the list and then add to it as the user scrolls down.
extras
ADT 12: Not so shiny after all
Passing complex objects to another Activity
Several months ago, I was faced with a problem of passing a complex object to another Activity. There are several ways of doing this:
- “Deconstructing” the complex object to simple data types and passing them as extras through
putExtra()
- Making the object
Parcelable
- Making the object
Serializable
intents
Sharing is Caring
Or so they say.
Passing complex objects to another Activity
Several months ago, I was faced with a problem of passing a complex object to another Activity. There are several ways of doing this:
- “Deconstructing” the complex object to simple data types and passing them as extras through
putExtra()
- Making the object
Parcelable
- Making the object
Serializable
adt
Where’s my R.java?
This afternoon, I tried importing an existing project into Eclipse. Doing a Project > Clean usually clears up the R.java not found errors, but this time it didn’t work. I tried re-importing the project, copy-and-pasting it into a new workspace, restarting Eclipse, but the error is still there.
ADT 12: Not so shiny after all
R.java
Adding a float value to your resources
Earlier today, I was trying to figure out how to add a float value to constants file. What I used to do was add a string value in my strings.xml
, retrieve the string value, and convert it to float.
float floatFromFile = Float.valueOf(getResources().getString(R.string.my_float));
Where’s my R.java?
This afternoon, I tried importing an existing project into Eclipse. Doing a Project > Clean usually clears up the R.java not found errors, but this time it didn’t work. I tried re-importing the project, copy-and-pasting it into a new workspace, restarting Eclipse, but the error is still there.
viewpagerindicator
Styling tab selectors for ActionBarSherlock
This post builds on the previous post for ABS + VPI.
Making ActionBarSherlock and ViewPagerIndicator play nice
EDIT (20121227): I made a new post on changing the tab selector underline.
EDIT (20121014): I received feedback from the comments that rotating the device will cause the tab contents to revert to the default text. In essence, the adapter “loses” the contents of the tabs. I have corrected this in the example below as well as in github.
EDIT (20120905): The full sample source code is now in github.
actionbarsherlock
Styling tab selectors for ActionBarSherlock
This post builds on the previous post for ABS + VPI.
Making ActionBarSherlock and ViewPagerIndicator play nice
EDIT (20121227): I made a new post on changing the tab selector underline.
EDIT (20121014): I received feedback from the comments that rotating the device will cause the tab contents to revert to the default text. In essence, the adapter “loses” the contents of the tabs. I have corrected this in the example below as well as in github.
EDIT (20120905): The full sample source code is now in github.
style
Stylish Dynamic Layouts
One of the things we are taught in Android is that we should gracefully handle different layouts based on screen sizes. With more and more things being not just screen size-specific but also OS version-specific, this is one thing I think a lot more devs need to pay attention to. Today was my turn to do just that.
Styling tab selectors for ActionBarSherlock
This post builds on the previous post for ABS + VPI.
ux
Troubleshooting autoVerify
So you implement app links and you are 300% sure you have implemented everything correctly. The important thing to remember here is that verification is all or nothing. From the docs:
A Little UX Love Goes A Long Way
Yesterday, my bank pushed a notification asking if I’m going to travel. Yes! I am! I filled up the form they asked me to fill up, and tapped Submit.
speaking
Time Check: 10 Minutes
Last year, I wrote about my talk preparation process. I mentioned that I try to practice my talk verbatim a bunch of times, especially the night prior.
All You Need is Just a Little Patience
Over the weekend, I gave a talk at Droidcon Vietnam about data binding and Plaid. One person told me that public speaking seems to come naturally for me and today I would like to illustrate how that came to be.
conference
Time Check: 10 Minutes
Last year, I wrote about my talk preparation process. I mentioned that I try to practice my talk verbatim a bunch of times, especially the night prior.
All You Need is Just a Little Patience
Over the weekend, I gave a talk at Droidcon Vietnam about data binding and Plaid. One person told me that public speaking seems to come naturally for me and today I would like to illustrate how that came to be.
deeplinks
Making ADB a little bit dynamic 📱
Android has a lot of tools for developers and one that has been around for as long as I can remember is Android Debug Bridge (adb
). It allows you to issue commands to an attached device, such as installing an app or starting an Activity
.
Debugging App Links in Android 12 🔗
I have been working with deeplinks lately and I noticed that quite a few things have changed since I last worked with them. The most important change is quoted in the list of Android 12 behaviour changes:
anti-stress
It’s so fluffyyyyyyyyy!!!
<img src=http://www.despicable.me/pops/minionMaker/userpics/910156207.jpg width=”380” height=”473” alt=”I’ve created a Minion to join Gru’s Minion army.” />
import project
Importing existing Android projects to Eclipse
When trying to import an existing Android project to Eclipse, I always encounter the error: The method *XXXXX* must override a superclass method
.
decimal
More plurals: decimal values
In my previous post, I showed you how to set string plurals. If you noticed, the methods to get the plurals strings only accept int
s. What if (like me) you want to display a decimal value? I am getting my raw value from a progress bar with a range of 1-10, with 0.1 increments.
hierarchyviewer
Missing hierarchyviewer in SDK 7
If you have SDK version 7, you are most probably missing the hierarchyviewer
from your /tools
folder. To check your SDK version, launch the SDK manager UI from your installation path, usually C:\android-sdk-windows
, then click About.
autoadjust
TextView and MaxLines
I have a TextView (who doesn’t?) and I want to adjust its height automatically, depending on the length of the text it will contain. Should be easy. It was, but it took me a couple of minutes to figure it out.
maxlines
TextView and MaxLines
I have a TextView (who doesn’t?) and I want to adjust its height automatically, depending on the length of the text it will contain. Should be easy. It was, but it took me a couple of minutes to figure it out.
grammar error
What grammar?
My OC side was alarmed when suddenly, my Problems view in Eclipse was filled with warnings on my XML files. Each of my XML files had a warning with it, and that little yellow exclamation mark on the side:
thumboffset
That damn seekbar thumb
If you have ever needed to use a SeekBar
, you definitely would have noticed how hard it is to move the slider (aka thumb) when it is set to the minimum or maximum value. The slider tends to be cut in half, and fitting your finger into it to press it becomes a test of patience.
slider
That damn seekbar thumb
If you have ever needed to use a SeekBar
, you definitely would have noticed how hard it is to move the slider (aka thumb) when it is set to the minimum or maximum value. The slider tends to be cut in half, and fitting your finger into it to press it becomes a test of patience.
css
Using a custom font in WebView
In one of my projects, I needed to display some special characters that the Android OS by itself cannot seem to render. I figured that I would need to provide a custom font that includes the characters that I needed.
font
Using a custom font in WebView
In one of my projects, I needed to display some special characters that the Android OS by itself cannot seem to render. I figured that I would need to provide a custom font that includes the characters that I needed.
webview
Using a custom font in WebView
In one of my projects, I needed to display some special characters that the Android OS by itself cannot seem to render. I figured that I would need to provide a custom font that includes the characters that I needed.
ScrollView
My EditText is cut off by the on-screen keyboard!
With clients demanding left and right that my app should look like an iPhone app, I tend to be unappreciative of the way Android natively handles UI interactions and such. Notice how the screen automagically scrolls up when you click on an EditText
? It turns out that in iPhone development, the developer does this manually (indicate how much the view should scroll when the on-screen keyboard appears, then scroll it back down afterwards). HA!
custom adapter
Using CWAC’s EndlessAdapter with a custom adapter
In one of my projects, the app has the potential to display a very, and I mean very, long list. To minimize the loading time of the app, I limit the number of items initially included in the list and then add to it as the user scrolls down.
endless adapter
Using CWAC’s EndlessAdapter with a custom adapter
In one of my projects, the app has the potential to display a very, and I mean very, long list. To minimize the loading time of the app, I limit the number of items initially included in the list and then add to it as the user scrolls down.
text color
Changing a button’s text color
There are times that when changing a button’s background color, we also want to change the text’s color. There is a method setTextColor(int color)
specifically for this purpose. Seems pretty straightforward enough, but it took me a few tries to get it right the first time I tried using it. Documenting it here so that I wouldn’t forget.
wishful thinking
Dreaming of Google I/O: ADT preview
It is my dream to one day attend Google I/O. But seeing as I’m from a Third World country where everyday is a practice in cost-cutting, it is very unlikely that I would fulfill that dream anytime soon. I haven’t sat down and computed the actual cost, but thinking about it makes my head spin. Off the top of my head:
- US Visa application = P6500 (~USD150)
- Round trip plane fare ticket = P90,000 (~USD2000, if I’m lucky)-
- Google I/O ticket = P21,000 (~USD450, if my research is correct)
Google I/O
Dreaming of Google I/O: ADT preview
It is my dream to one day attend Google I/O. But seeing as I’m from a Third World country where everyday is a practice in cost-cutting, it is very unlikely that I would fulfill that dream anytime soon. I haven’t sat down and computed the actual cost, but thinking about it makes my head spin. Off the top of my head:
- US Visa application = P6500 (~USD150)
- Round trip plane fare ticket = P90,000 (~USD2000, if I’m lucky)-
- Google I/O ticket = P21,000 (~USD450, if my research is correct)
complex values
Passing complex objects to another Activity
Several months ago, I was faced with a problem of passing a complex object to another Activity. There are several ways of doing this:
- “Deconstructing” the complex object to simple data types and passing them as extras through
putExtra()
- Making the object
Parcelable
- Making the object
Serializable
the 90s rule
A break: When I grow up
Tearing my hair out on my latest project. So here’s some Garbage to cheer me up.
authentication
MongoDB and Authentication
By default, MongoDB allows access to the database without authentication. Adding a user with a username/password is easy, but authenticating might be a bit tricky since the official documentation does not say the command directly.
mongodb
MongoDB and Authentication
By default, MongoDB allows access to the database without authentication. Adding a user with a username/password is easy, but authenticating might be a bit tricky since the official documentation does not say the command directly.
selenium
Selenium and File Downloads
Lately, one of my tasks has been to automate regression tests on one of our apps. Since this is a web app, we are using Selenium. Here, I enumerate the steps to configure Firefox for file downloading using Selenium and JUnit by foregoing the downloads dialog box.
JUnit
Selenium and File Downloads
Lately, one of my tasks has been to automate regression tests on one of our apps. Since this is a web app, we are using Selenium. Here, I enumerate the steps to configure Firefox for file downloading using Selenium and JUnit by foregoing the downloads dialog box.
file download
Selenium and File Downloads
Lately, one of my tasks has been to automate regression tests on one of our apps. Since this is a web app, we are using Selenium. Here, I enumerate the steps to configure Firefox for file downloading using Selenium and JUnit by foregoing the downloads dialog box.
clone
Quick Tip: git cloning
A user-friendly way of cloning a git
repo is through the eGit plug-in in Eclipse. But sometimes, especially on Windows machines, Eclipse has trouble cleaning up after itself after completing a clone operation. The best workaround for this is to clone the repo from git bash
and then import the repo in Eclipse.
default@ZDOMINGUEZ-T420 ~
$ git clone git@github.com:<your git repo> <local folder to check out to>
float
Adding a float value to your resources
Earlier today, I was trying to figure out how to add a float value to constants file. What I used to do was add a string value in my strings.xml
, retrieve the string value, and convert it to float.
float floatFromFile = Float.valueOf(getResources().getString(R.string.my_float));
submodule
Cloning a remote branch in git
My current project at work uses git, and I have always been a CVS/SVN baby so I’m still trying to find my way around it. Today I wanted to clone a remote branch to my local computer. This remote branch also has submodules, so I want to get those too.
remote branch
Cloning a remote branch in git
My current project at work uses git, and I have always been a CVS/SVN baby so I’m still trying to find my way around it. Today I wanted to clone a remote branch to my local computer. This remote branch also has submodules, so I want to get those too.
logcat
Save Logcat contents to file
Note to self: to save the contents of Logcat to a text file:
connectivity
I Can Haz Internetz!
Last week, I was exploring connectivity monitoring and came up with a small app for demo. The app listens for connectivity changes and sends a notification to the user informing them of the change.
notification
I Can Haz Internetz!
Last week, I was exploring connectivity monitoring and came up with a small app for demo. The app listens for connectivity changes and sends a notification to the user informing them of the change.
utils
Quick Tip: Checking for emptiness
Always using if(myString != null && myString.length() > 0)
? Use !TextUtils.isEmpty(myString)
instead.
gps
Quick Tip: Updating the location update frequency
When using Google Play’s Location Services and you want to change the frequency of the updates, make sure to do these in order:
location updates
Quick Tip: Updating the location update frequency
When using Google Play’s Location Services and you want to change the frequency of the updates, make sure to do these in order:
swipe to refresh
Swipe, not Pull, to Refresh
I have recently came across this new View in the support library package that allows your app to have built-in support for pull swipe to refresh. This is pretty cool, since we don’t have to use any of the libraries out there. Admittedly, very little customization can be done, but then what else can we customize, right?
database
SQLiteAssetHelper + ORMLite
I recently had cause to use Jeff Gilfelt’s SQLite Asset Helper library. For those unfamiliar, it is a library that can help with including a pre-populated SQLite database with your Android application. It is extremely convenient with unbundling a potentially huge database you would want to ship.
sqlite
SQLiteAssetHelper + ORMLite
I recently had cause to use Jeff Gilfelt’s SQLite Asset Helper library. For those unfamiliar, it is a library that can help with including a pre-populated SQLite database with your Android application. It is extremely convenient with unbundling a potentially huge database you would want to ship.
material design
On being material
In case you missed it, I made a blog post about updating our app to material design. In it I talk about what material design is and what we did to adopt it. I hope you enjoy reading it as much as I did writing it. :) Head on over to Domain’s tech blog for the details.
podcast
In which I was in a podcast
It has been a month since IO and in case you missed it, I got to chat with Kaushik of Fragmented. And by golly, I made it into an episode! At that point I was about to lose my voice, so I sound really husky. :p
open source
A big step
Today was the day.
talks
Tools of the Trade
Here are the slides to my talk at the Android Meetup tonight.
tech talk
Tools of the Trade: Unabridged
I gave an unabridged version of my last Android Meetup talk at this year’s YOW Conference. It has been an honour being part of this awesome conference!
gde
Tools of the Trade: Unabridged
I gave an unabridged version of my last Android Meetup talk at this year’s YOW Conference. It has been an honour being part of this awesome conference!
nougat
The Quirks of Supporting SDK 25
The last developer preview of Android 7.1 has started shipping, which means APIs are (based on past experience) more or less stable. There is a very good write up on developer.android.com on how to get started with supporting these new features. I set about trying it out, and here’s what happened.
app links
Troubleshooting autoVerify
So you implement app links and you are 300% sure you have implemented everything correctly. The important thing to remember here is that verification is all or nothing. From the docs:
wtm
Android is like baking
Today I had the honour of attending the first WTM Summit in Sydney.
plaid
@{app.plaid}
I gave a talk this morning in the first ever Droidcon Vietnam! It is about two of the things I love in Android – Plaid and data binding.
io17
There is Always Room for Improvement
During the beginning of my Android career, one of the things I had to do was to save some data to somewhere. I found out that for my purposes, I had to use an SQLite database. Reading through the docs, I was afraid. Petrified, even.
arch
There is Always Room for Improvement
During the beginning of my Android career, one of the things I had to do was to save some data to somewhere. I found out that for my purposes, I had to use an SQLite database. Reading through the docs, I was afraid. Petrified, even.
quick tip
Children, Respect Your Parent(s)
I was updating a bit of code the other day that involved dynamically inflating views into a LinearLayout
using DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.row_related_property, container, false)
.
bye
Next Move
Today is my last day at Domain. After three years, seven months, and three days, it is time to move out.
constraint layout
Effectively Wrangling Together a Bunch of Views
One bit of task that I find myself doing over and over again is managing a bunch of View
s and their visibility. In the olden days <insert old person handwave>, before there was ConstraintLayout
, I have written my fair share of container_
s to make this task manageable. Say we have to do something like this:
musings
Your Privilege is Showing
When I left the Philippines five years ago, I had a high-paying job at the heart of the country’s financial district. I was living a very comfortable life: I can afford an annual membership to a yoga studio, I bought an off-the-plan apartment with views of Manila Bay, I get to treat my parents to a holiday once in a while, I get to travel with my friends – we were even able to go abroad a couple of times!
a11y
Seeing What Talkback Sees 🔍
One of the things we should be doing as Android developers is to ensure that our apps are as accessible as possible. There are a bunch of talks and articles that discuss the motivations behind current MDC a11y support, the basic steps to support a11y, testing overviews, even creating your own a11y service!
accessibility
Seeing What Talkback Sees 🔍
One of the things we should be doing as Android developers is to ensure that our apps are as accessible as possible. There are a bunch of talks and articles that discuss the motivations behind current MDC a11y support, the basic steps to support a11y, testing overviews, even creating your own a11y service!
firebase
📣 PSA: Disabling mapping file uploads with Crashlytics
One of the more famous crash reporting tools used in Android development is probably Crashlytics. It offers up a lot of insight into an app’s performance – from device characteristics to insights on issue commonalities. If, like my current project, obfuscation is enabled in an app, Crashlytics has a Gradle plugin that uploads the mapping file so that we end up with readable crash reports.
crashlytics
📣 PSA: Disabling mapping file uploads with Crashlytics
One of the more famous crash reporting tools used in Android development is probably Crashlytics. It offers up a lot of insight into an app’s performance – from device characteristics to insights on issue commonalities. If, like my current project, obfuscation is enabled in an app, Crashlytics has a Gradle plugin that uploads the mapping file so that we end up with readable crash reports.
parcelize
Bundling Things Nice and Pretty 💝
Of all the projects that I have worked on over the years, one thing they all have in common is the need to pass things around. Whether passing stuff to an Activity
as Intent
extras, a Fragment
as arguments or its onSaveInstanceState
, or even a ViewModel
’s SavedStateHandle
, the most common way to do it is through a Bundle
.
kotlin
I Dub Thee… Marginally better at RegEx
Being a perpetual RegEx n00b, one thing I keep on forgetting is that it is easy to get tripped up when extracting information from an input.
regex
I Dub Thee… Marginally better at RegEx
Being a perpetual RegEx n00b, one thing I keep on forgetting is that it is easy to get tripped up when extracting information from an input.