Web API testing tools - Postman

Whatever you are developing, you are most likely contacting or creating a web API. For quickly testing web APIs, there are numerous tools you can use to do requests, instead of before implementing everything in code. This can quickly speed up the development process, and discover bugs and problems with the API early. For almost two years now, I have been used to using Fiddler for doing HTTP requests and testing APIs. Postman A few days ago, I came across

» Read more

Android Volley library - Fixing the empty POST parameters

Recently, I came across the Volley library for Android. I already had an app that used network requests, to post and get data from a Node.js webserver with Express.js. The code I had for doing the network part, downloading JSON data and images, with memory and disk cache of images, was working fine, but I thought I’d make use of volley instead. As it had better support for certain things, one of them; grouping and cancelling requests

» Read more

Got a problem with spaces in strings.xml getting stripped away?

If you have a string in your strings.xml file that you want to have a space character in front or after the string itself, you may notice that this space gets trimmed away automatically. To avoid the string getting trimmed away, you can use one of the following tricks: Trick one – Wrapping the string in quotes If you wrap the string in a pair of quotes, the space will not get stripped away. Also, the quotes themselves does not

» Read more

Linode - The best VPS host

A couple of years ago, I was looking for a good place to host a VPS, with this blog, and other stuff. After testing out a couple of known and little known services, I stumbled across Linode. The VPS you get for your money, is absoslutely worth it! They have a pretty powerful starter plan, with 1 GB of ram and 48 GB of storage. Theres great guides and support for setting things up. Great performance, uptime and customer support.

» Read more

How to extract strings into strings.xml resource files in Android Studio

I have previously posted a guide on how to extract string resources in Eclipse, so I thought I would do it for Android Studio too, as it is not directly obvious how to acheive this. All your applications strings should be placed in the various /values/strings.xml files in your app. This is the best practice, gathers all texts, and easily enables you to translate your app into other languages. While developing apps, it might be easier to just

» Read more

How to detect changes to your Android Preferences

This will demonstrate how to listen for changes to the user preferences in your app, so  that you can perform tasks depending on what the user selected/changed on the preferences screen. I have an app, with a listfragment displaying rows of text. There is also a preferences screen (SettingsActivity.java) where users can set the sorting order of the list. When users change the sort order, the list should be refreshed, to disaply the items in the new order.

» Read more

Delayed task execution in Java and Android

If you need to do some delayed task in for example your Android App, you can easily achieve this with a Java TimerTask. This is a short example, where some method ( removeDialog() ) is run with a delay of 2 seconds. //import statements import java.util.Timer; import java.util.TimerTask; //in your method, use the Timer Schedule function: new Timer().schedule( new TimerTask() { @Override public void run() { removeDialog(); } }, 2000 );

» Read more

Android SQLite Sort order does not work with upper and lowercase letters

If you are using SQLite database, with a Cursor or Perhaps Content provider, you may have come across alphabetical sorting problems regarding upper and lowercase letters. Perhaps you are requesting a cursor from a Content Provider: String[] projection = { Table.COLUMN_ID, Table.COLUMN_TITLE}; String sortOrder = Table.COLUMN_TITLE + " COLLATE NOCASE ASC"; CursorLoader cursorLoader = new CursorLoader(this, YourProvider.CONTENT_URI, projection, null, null, sortOrder); The solution to the alphabetical sorting problem is the COLLATE NOCASE in the part of the

» Read more

Android Emulator: How to access the sqlite database of an app

This is an example of how to access the sqlite database of an Android app running on an emulator. Make sure you have the android adb tool on your PATH. Run this command in the terminal: adb version If you have adb on your path, it should show something similar to this: Android Debug Bridge version 1.0.31 If not, follow this guide: Adding the adb tool to the terminal for easy access. Accessing the SQLITE database Open a

» Read more

Adding the Android adb tool to the command line

If you need to use the adb tool that comes with the Android SDK, you can easily add it to the command line. This example is on OS X, but also works on different Linux distros such as Ubuntu. The adb executable is located in the /platform-tools folders, where is the path to here you installed (unzipped) the Android SDK. Open a terminal, and type echo $PATH. This is your systems PATH variable, containing a list of folders separated by

» Read more