Android – Basic testing with unit test, android test and roboguice, robolectric, mockito

Bugs are always the most annoyed things for developer. It’s a dream (which never comes true) that a software runs without any problem at client’s site. There are always some points that developers have to improve after deployment. The more time developers invest for testing, the better the software is and the less annoyance developers have. I made many examples of Android development which are small apps and illustrate how a point of interest works. As a demo, I didn’t care too much about if there is a bug in app code because it isn’t a complete application. However if we want to make something that can be sold to customers, we have to be sure that our software should be reliable as it could be. Therefore in this post I would like to discuss some simple basic tests in Android development. We will learn how to write a logical unit test with JUnit, an integration unit test with test classes from Android and some advanced test cases with Roboguice, Robolectric and Mockito.

Continue reading

Sqlite with Entity Framework Code First and Migration

Last month I’ve a chance to develop an app using Sqlite and Entity Framework Code First. Before I started with this project, I thought everything will be easy because Sqlite and Entity Framework are both popular framework. Maybe I just need to install some nuget packages and it will work like a charm. But… yes, there is always a ‘but’ later, it’s just not so easy. Especially when I usually work with NHibernate than Entity Framework. The installation doesn’t complete his job when configuring the .config file (or maybe it just happens for me or does the author do it with intentionally?) and the Migration for Sqlite Entity Framework Code First is not supported (please correct me if I’m wrong). There are, of course, commercial products for Sqlite Migration but I prefer an open source framework or something free :). So in this post I would like to write down the steps required when starting a project for Sqlite Entity Framework Code First and how I make my own simple Migration engine.

Continue reading

C# – Lotus NotesSQL Driver install, configure and connect to server through ODBC

Lotus Notes and Lotus Domino are the client and server of a collaborative client-server software platform from IBM. The ecosystem provides business collaboration functionality, including email, calendars, to do lists, contacts management, discussion forums, file sharing, instant messaging, blogs, and user directories. Like other business applications, Lotus system conducts a database system behind to manage all data objects for sharing data between internal applications. To make the system itself more friendly to 3rd applications, Lotus also provides a driver – Lotus NotesSQL – so that 3rd applications can query data from Domino server. With Lotus NotesSQL, users and application developers can integrate Domino data with their applications through ODBC. IT professionals can enable their existing ODBC-enabled applications to access data stored in a Domino database. It allows ODBC-enabled data reporting tools, database tools, and application development tools to read, report, and update information that is stored in Domino databases (NSF files).

Continue reading

Android – Sqlite database with ContentProvider and LoaderManager

If you follow my previous posts, you may already know that we discussed how to make an application with database in Android before in Android, Dependency Injection (IOC) with roboguice and MVVM (Model-View-ViewModel) pattern. Although the main topic in that article relates to Dependency Injection but we had also a working example which fully supports all CRUD actions for Sqlite database. However, in practice, it shouldn’t work like that because the synchronous read/write actions will block the user interface and your apps will freeze. When your database grows over time, the query time gets longer and you app will completely freeze during the query get executed. Therefore, in this post, I would like to make a sample for illustrating how a database application can work in asynchronous mode.

Continue reading

Android – How to speed up Android emulator?

Android emulator is very famous for its performance. It’s very, very, very notoriously… slow. If you debug your app with Android emulator, it get more extremely slower. This performance problem stems from the fact that Android OS is written for ARM processor (not for Intel/AMD processor or let’s say not for computer processor). Therefore when we get our apps run on Android emulator (which is running on Intel/AMD processor), every assembly code row has to be emulated. A run-time binary translation will happen to translate every assembly code of development machine to device machine. And that point slows down everything.

Continue reading

Android – Show images from Flickr with ImageGridView

Flickr is a wonderful image hosting and video hosting of Yahoo. With a free account, you can get a disk space up to 1 TB for uploading and sharing your photos as well as videos. In this post, I would like to make a small demo showing how we can consume the Flickr’s REST web service and display public images of an album on Android phone. The images could be shown either in thumbnail mode or medium mode. The example app is just a proof of concept, you have to improve it when you want to build a same one in practice because I just don’t care about optimizing resources (memory) in source code. You will also ‘learn’ how to implement a singleton pattern (in entire app) with roboguice. That means, small example, interesting use cases.

Continue reading

Android – Build tab layout with FragmentPagerAdapter, ViewPager and ActionBar

Tab control is a popular component in desktop application. I think, most of desktop application contains at least a tab control in one way or another. In Android environment, we also have a tab control named “TabHost”, but since Android 3.0, it was replaced by ActionBar. In this post I would like to show how we can make a “fake” tab layout with ActionBar so that we can give user the same experience like TabHost. This control is built up by a combination of ActionBar and FragmentPagerAdapter. The labels will be located at the top, switching between tabs will load the content of the tabs. Moreover thanks to touch screen of smartphone, user can also swipe to navigate between tabs. The final result of our “fake” tab layout looks like following image (Please note that we aren’t going to make a “tab control” but a “tab layout”, they are different concepts)

Continue reading

Android – Upload files to ASP.NET Web API service

In previous posts, I showed you how to get/post data to ASP.NET Web API service. However, until now, I only used JSON for communicating between server and client and what about for binary data? For example, uploading files to ASP.NET Web API? How should the controller work and which kind of HTTP request/HTTP format should the Android client send to server? In this blog post, I will show you a simple way to transfer binary data. In the demo, I have 2 components : web service and android client. Unlike the other post, for this one, unfortunately, I don’t have any sample web service (online over internet) for you to test. I don’t own any windows server (neither VPS nor dedicated server :() therefore I can’t host any web service allowing file uploading.

Continue reading

Simplicity is the ultimate sophistication – Leonardo da Vinci