Yes, another project has been born. This time I want to make an Android application and deliver the first beta within one week. I found out my Android experience is a bit rusty, but I am picking up the pace again.
The application is supposed to administer all your activities. With a point system it can judge if your day was too busy or not. Initially I will design it for the following devices in this order. The resolution of the first device makes it possible to show a whole week on one screen in landscape mode.
|Device||Android version||Screen size||Screen resolution|
|Galaxy S2 tablet||Android 5.0.2||9″ screen,|
4:3 screen ratio
|2048 x 1536 pixels|
|Sony Xperia Z1 Compact||Android 5.1.1||4.3″ screen||720 x 1280 pixels|
|Nexus 6P||Android 6.0.1|
|5.7″ screen||1440 x 2560 pixels|
When adding an activity you can select the following parameters:
– A description. When an activity is entered, the parameters associated with it are cached for the next time you use it again.
– The intensity of the activity is:
– A time and duration can be entered. Initially it will support time slots starting and ending at :00, :15, :30 and :45.
I assumed it was an easy task to do. Just make a screen with a GridLayout, format the basics like the time and day, exchange the data with an SQL server and it is done. Now, partially true, but also very wrong. You will find out in a minute.
Step 1: Android skeleton
Make a new Android app with Android Studio. Choose the name of the application (Activity) and the domain (diystuff.nl.activity). Select the android version (API 21, Android 5.0 lollipop) and select it to be a Tabbed Activity. Let it take some time to get the indexes right and build the app initially.
Step 2: Setup Hosting
Where to host the database. That wasn’t that hard. There is a free webhosting somee.com which hosts an SQL server. There I added a database. I wanted to choose the latest SQL server 2014 version, but all 2014 servers were booked full. I had to select a lower version, in this case MS SQL 2012 Express. On Somee it is also possible to choose SQL Server 2008 R2 as a third option.
Do not use the “SQL Server Object Explorer” within VS2015 to do actions on Somee, this is really slow! You can use it to generate some SQL script and execute this at the management interface on Somee.
CREATE TABLE [dbo].[tblAccount] (
[AccountId] UNIQUEIDENTIFIER DEFAULT (newid()) NOT NULL,
[AccountLogon] NVARCHAR (50) NULL,
[AccountPasswordHash] NCHAR (64) NULL,
[AccountFullName] NVARCHAR (512) NULL,
[AccountEmail] NVARCHAR (256) NULL,
PRIMARY KEY CLUSTERED ([AccountId] ASC)
But can the SQL server be reached from Android directly? The answer is NO. You need to make a webservice to access the SQL server which is accessible from Android applications directly. Ofcourse it is possible to contact the server directly (as discussed on Stackoverflow, the best resource out there for programmers) but everywhere I find hints to use a WebService in between.
Step 3: Program a Webservice
Here follows a short walkthrough to get the Webservice code. I did it by starting Visual Studio 2015. There you need to create a new “ASP.NET Web Application” project. Inside the solution right-click on the WebApplication project and Add->New item. There you select Web Service (ASMX). this makes the skeleton code for the external methods.
Step 3: Use Entity Framework
Add new item->ADO.NET Entity Data Model. Click “EF Designer from Database”. Click on “New connection” Select the server name, logon via SQL authentication type in the database name. Don’t use the dropdown, there are too many databases on the Somee server. Make sure to click “Test connection”, then you are sure the information is correct. Click on OK. Select the tables you are interested in.
Step 4: Hook up android code to running Webservice