« Posts under Programming

Parallel Image loading performance in Android

I just ran into the problem that I have to load a whole bunch of images in an Android application, so I wondered about the performance of parallel image loading and how many images can be loaded simultaneously. Therefore I wrote a small benchmark app that loads about 100 images (each between 4 and 7 KB) from a webpage. I admit, the app could be written better, but for my purpose it should be fine.

I measured the time in seconds that it took to load all images without displaying them in a View. 0 Threads means that all images were loaded in a sequence. A Thread count above 0 means that I created a new AsyncTask for each image and ran n of them at the same time.

»Read More

Login to the Foursquare API v2 from Android with OAuth

Once you figured out how OAuth works, you might ask yourself how this principle works from within a native Android app. It’s actually easier then expected at first. There exist some libraries that can make our life somehow easier, but I decided not to use any of them and to do everything from scratch.

This is the OAuth workflow for Foursquare:

  • A call to the Foursquare server is made with the client id and a redirect URL (has to be in a browser)
  • The user accepts the access request of the application
  • Foursquare calls the redirect URL with special code as parameter
  • The Foursquare server has to be called again with the client id, client secret, the code and the redirect URL (not in the browser anymore)
  • Foursquare returns now the access token which has to be saved by the app
  • Further calls to the Foursquare API can be made with the token

»Read More

Login to Foursquare with an Android App using OAuth

Note: This tutorial is for the Foursquare API V1. A version for v2 can be found here.

Although the Foursquare login process is pretty easy, it took me some time to figure out how this could be done from an Android application. The problem here is, that I don’t want a Popup window for the OAuth login. There’s a different requirement for the whole login process.

A standard OAuth login process consists of this flow:

  • Create consumer with application token and secret
  • Get login URL from service
  • Redirect the user to the login URL
  • User grant or deny access to service
  • Get the access token and secret

But in a mobile application, without a URL redirection, what we actually want is something like this:

  • Create consumer with application token and secret
  • Login to service
  • Get the access token and secret »Read More

Define some items in a ListBox as unselectable

It seems to be a quite common problem that one does not know how to set one or more items in a ListBox to unselectable or disabled.

The same principle as described here can also be user for similar problems like setting a different background color for some items.

First we’re going to create a simple domain class with a property that describes if the item should be selectable or not.

public class MyDataObject {
    public string Name { get; set; }
    public bool IsSelectable { get; set; }
}

»Read More

An easy way to revert changes in Object data

A quite common problem in an MVC GUI is the need to revert changes in the model made by the user. Let’s say you create a UI where the user can modify some fields that are bound to a model object. After the user already did some changes, he recognizes that he entered some wrong data and wants to cancel the editing. So what now? The data is already written into the model.

The easiest way to revert this changes is obviously to let the user work with a copy of the real data object. So let’s add a clone method to the model and mark it as Serializable. »Read More

Access a Zend Rest Service from C#

Accessing a Restful service is actually no big deal, but it took me quite a while to figure out some details. So here’s a short description of it.
»Read More

PHP Webservices with the Zend Framework

With the Zend framework you can choose between Rest-, XmlRpc- and Soap-Webservices. I am going to describe here all of them with a simple ping service. »Read More