A Simple Callback in Java for Android

It all started when I received a NetworkOnMainThreadException while testing an Android prototype that makes an HTTP request to my backend. It means simply that you can't make the request in the main thread. So the quick and proper solution is to extend AsyncTask for it: public class FooJob extends AsyncTask<String, Void, Response> { @Override protected Response doInBackground(String[] params) { Log.i(TAG, "job started"); Response response = doSomething(params); return response; } @Override protected void onPostExecute(Response response) { Log.i(TAG, "job ended"); } } Then you…

Keep reading

New Setup Essentials

When I switch to a new computer, I always struggle to find which applications to install immediately to expedite the transition. So here's a checklist that I have created for myself, as I'm currently going through this process and don't want to have the same issue next time.…

Keep reading

Managing Mailbox

It appears like majority of the people I meet are a fan of "archiving". Creating an archive of photos, music, movies, TV shows - everything. We love to keep things that would become a memory some day. Who doesn't have a notebook from 10 years ago hidden somewhere on the shelves or under the bed? I bet no one. That is a natural urge. We apply the same intuition to our written correspondences as well. I have seen people create an archive directory for their emails which then…

Keep reading

Avoiding Chaos

I don't know about you, but I have a dozen different responsibilities in my personal and work life combined. Multiple projects in the office, constant KTLO time spent on administrative jobs at home. This leads to a packed schedule, where being productive suddenly becomes a requirement and even an addiction. I follow zero-inbox strategy[1], which works quite fine; as of writing this post I have only 3 emails in my inbox. Prioritizing tasks in a packed schedule is a different kind of story, but what I will focus on…

Keep reading

Smartphone But No Internet

2 weeks ago when I was on a short vacation, I consumed almost all of my data allowance in 5 days. Now I'm left with no internet, but the temptation to purchase an additional package for a couple of pounds only. Yet I've been resisting this urge for more than 10 days now. Let me tell you first, this is not an I have found the meaning of life, this is an amazing experience post. My motivation was to experiment what it would have been if I didn't have internet…

Keep reading