Wednesday, December 29, 2010

Delphi for Android v0.3 Tutorial

Delphi Prism support iPhone and Android application development using Monotouch and MonoDroid where the goal of Delphi for Android ("Delphi Droid" for short) is to allow any developer that has Delphi 5 onwards to write Android applications.

This is a short tutorial on how to get started with Delphi Droid compiler version 0.3 as it currently is.

Note: The compiler isn't complete, there is still ALOT of work to be done. If you wish to help with the development, please contact me to contribute.

Requirements:
  • The Android SDK together with the Java SDK and Ant. Ant get used to compile the Android application since DelphiDroid generate a standard Android project (similar to how you do it using Eclipse)
  • Download DelphiDroid_v0.3.zip from the Google Code page.
  • Off course you need Delphi 5.0 or later.
  • .Net framework 3.5 run-time
What is in the ZIP:

Within the ZIP file you will find the following directories:
  • bin: There is where the compiler etc are located. You can set this as your SYTEM VARIABLE to call from command line.
  • DelphiDroid/DCCDroid: C# source code of the compile. This can be compiled using MS Visual Studio.Net 2008.
  • DelphiDroid/Framework: The "Delphi For Android" package that all Delphi applications require.
  • DelphiDTest: The Delphi example as in Sneak Preview 2 video.
  • Test: The actual Android projected generated by the compiler from the DelphiDTest example.
Setup Android SDK etc:

I'm not going to explain how to setup the Android SDK, I assume you already have knowledge on how to install the SDK, set it up etc.

Setup the compiler:

Within the bin folder you will find DCCDroid.exe.config file, open this using a plain text editor like Notepad:

  • Change the AndroidSDKDirectory to the location where you installed the Android SDK.
  • Change DelphiBinFolder to the location of the Delphi BIN folder that contains the Delphi compiler etc.
Run the sample program:

Open DelphiDTest and make sure it compile and run successfully in Delphi.

Run the compiler with no parameters:

Open the MS DOS Command prompt and run:

DCCDroid.exe

The output:

Delphi For Android 0.0.0.3 Dev Build
Copyright © 2010 by Lennie De Villiers

Invalid arguments, the following arguments are required:

Project Name - Name of the project
Activity Name - Name of the activity
Package Name - Java package name
Input Source Path - Delphi source directory path
Android Output Path - Android output directory path



So this is very basic command line parameters, i don't need to explain how they work.

You can open compile.bat file under the bin folder for an example:

dccdroid.exe DelphiAndroid DelphiAndroid com.test c:\Demo\DelphiDTest c:\Demo\Test
copy C:\Demo\bin\Android.Framework\*.* C:\Demo\Test\src\com\Test
cd c:\Demo\Test
ant debug

This will compile the example program (assuming the location like c:\Demo) , copy the Android libraries and compile the program.

When all is done you can run the run.bat file:

cd c:\Demo\Test\bin
adb shell rm /data/app/com.test.apk
adb -s emulator-5554 install DelphiAndroid-debug.apk

This will install the sample on the Android emulator.

You can look at compile.bat and run.bat to write your own compile/run scripts.

What is done:

Just like I said before, there is still ALOT of work to be done. Currently only the following components are supported:

TEdit
TLabel
TButton

References:


Mailing Lists:

Users:

http://groups.google.com/group/delphi-for-android-users

General users.

Developers:

http://groups.google.com/group/delphi-for-android-developers

Donations:

If you can't donate your time but wish to don't some money to help with the development, then please contact me.

Tuesday, December 14, 2010

Delphi For Android Future

Now what has Lennie been doing all the time? Am busy working on a new version of the compiler that got a couple of surprises in it... So stay tuned until next year in January 2011 when I will release the first version of the new compiler :-)

Friday, October 29, 2010

DelphiDroid Compiler, Why C#?

Why have I written the DelphiDroid compiler in C#?

C# is the language that I use the most for 90% of all development.... 5% Java and the other 5% in other languages like PHP or Delphi etc. So yes its the language that I got the most experience in currently.

The compiler is also base upon the work I did for the C# For Blackberry toolset (This tool allow you to use C# to code for Blackberry mobile devices).

Saturday, October 16, 2010

Delphi For Android Going Open Source

After a lot of consideration, research etc I've decided to release DelphiDroid (Delphi for Android) as open source. The project is now available for download from the Google Code project page over sub-version.

Over the next couple of days I will release:

- Guide to how the tool works
- A Road Map
- Contribution Guide

Is it ready for production use yet?

No not at all, there are still ALOT of work to be done before its ready for use to write a full application with.

Please subscribe to the development mailing list or contact me if you wish to help.

How are you planning to make money?

By offering my services as a software developer and accept donations etc.

Mailing Lists

Users:

http://groups.google.com/group/delphi-for-android-users

General users.

Developers:

http://groups.google.com/group/delphi-for-android-developers

If your a developer.

Sunday, October 10, 2010

Delphi For Android Progress & Component Poll

Currently focusing on:
  1. Project planning for the next Sprints until first Beta version and first release version 1.0
  2. Indicate Application Icon and other assets
  3. Write Android specific components like TDroidButton (extend TButton), TDroidLabel (extends TLabel) etc that only have Android specific properties/methods/events.
  4. Library support: You can write your own libraries, this will help extending the tool (will blog more about this later)
  5. Audio and video support
  6. Images components
  7. Activity library to manage the activity events etc
  8. Sample applications
All above is still part of the Activity, later tasks add support for Android Services, Intents, Broadcast Receivers, Content Providers, Widgets etc.

Other notes:


C++ Builder support will be added much later and isn't part of this release version 1.0.
Lazarus/Delphi Prism support much later.

Twitter Poll: Create your own Delphi->Android components?

Please fill in the poll here.

I use polls to get feedback on what direction to take in the tool.... Sometimes to make a design decisions is difficult and for that I ask feedback.

Currently all components like TButton etc will have Android specific version that only have Android properties/events.

Only myself can write additional components.

Monday, September 13, 2010

Delphi For Android: Run Under Mono 2.4

The Delphi for Android tool (DCCDroid.exe) run under Mono 2.4 and later.
I haven't tested on a Linux/Mac OS X machine since we don't support Lazarus and Delphi Prism.

More questions time:

Lazarus and Delphi Prism support.
Lazarus support will take while to implement and test on Linux (even if DCCDroid.exe run on Mono) also Delphi Prism use a total different form design (WPF). For now I've decided that its better to focus on pure Delphi support and later on think about Lazarus/Delphi Prism.

Friday, September 10, 2010

Delphi For Android - Lazarus (Free Pascal) Support

DCCDroid doesn't work with Lazarus (Free Pascal) IDE because it reads the form layout to know where to place the controls on an absolute layout position as well as getting the control properties (like text, width/height etc).

Lazarus use a different file format (*.lfm) where Delphi use the DFM file layout.

Another question I received:

How does the tool work internally?

Now that is a top secret inside trade secret! Just to say that it does compile to a native application (not a web application) using the Android SDK. You don't need to deploy any special run time etc. Underneath it use the Android tool chain.

The inner details am not going to share.

Thursday, September 9, 2010

Delphi For Android Sneak Preview 2

In this preview:

- Running in Delphi 2006.
- TEdit and TLabel control together with event on TLabel
- Control properties, you don't need to write anything special just to get or set the value from a control... Just use the property like you always have!
- Actually show you the compiler and what the compile.bat and run.bat files do.

I will try to post a sneak preview at least every month but that depends upon the current Sprint size since each month I set myself a set of goals to archive.

For questions, comments, suggestions please contact me: lenniedg@gmail.com
Twitter: http://twitter.com/delphi_android



What's Next?

- Samples, include all the examples in the package.
- Additional controls
- Additional work on the core tool framework / libraries
- Library support: Allow you to write your own library.

Frequently Asked Questions (FAQ)

What versions of Delphi are supported?

Currently it runs in Delphi 7, 2006 and 2010. Haven't tested with the new Delphi EX yet. Delphi Prism not at all.

Is there Kylix support?

No, and no plans at the moment since Kylix is seen as a dead product.

Is there Lazarus (Free Pascal) support?

No but it should work with Lazarus. I will give it a try.

When will it become available?

Can't say for now since there is sooo much work still left. There will be a beta version but licensing, cost etc unknown at this stage.

C++ Builder support?

See poll below.

In what language is it written in? Delphi?

It's written in C# targeting .NET framework 3.5. The library "Delphi for Android" that you use in Delphi is the only part written in Delphi.

Does it run on an actual phone?

Yes it does, I tested it on my HTC Desire.

What target of Android is supported?

The tool for now default to Android 2.1 but you will be able to indicate the target. Minimum target I guess will be 1.6

Other platforms - iPhone? Symbian? Samsung Wave?

Not now sorry... Am only 1 guy you know :)

Anyone using this yet in a real world application?

I'm giving demos, getting comments and alot of suggestions but for now the tool isn't at a stage yet to be avialable to write a full real world application. For one, you can't sign your application yet for public release.

Poll

I got some suggestions on adding support for C++ Builder.... I'm not going to jump to add support now since that will side track the original project plans etc that will extend delivery since am sure everyone want a working copy to play with soon! For now please fill in the poll and let me know.

Donation

As a contractor a donation would be nice since that will help me to spend more time (time = money as a contractor) to work on it.










Delphi For Android Target Poll

After receiving alot of questions if Delphi For Android will target C++ Builder as well I decided to put this poll up to help me see where I should take it... If I should spend the time now or later.

Saturday, September 4, 2010

Delphi For Android - Sneak Preview

I love programming in Delphi, it was the first Windows development tool that I used after coming from QBASIC and Turbo Pascal 7.0 on MS-DOS (with my old 386SX machine, 2.1GB HD, 6MB RAM).

This is a sneak preview on what I've been working on for the last 2 months... This tool allow you to write Android mobile phone applications using Delphi.

In the first Youtube video I show how you can place a button (TButton) and then call a Android library method to display a message, run the compiler from the command line (its called "dccdroid.exe") and run within the Android emulator.

Tool has been tested with Delphi 6.0, 7.0, 2005, 2006 and 2010.

So how does it work?

The tool is written in C# with Visual Studio.Net 2008. It reads the Delphi form layout (dfm) and then create the XML layout file (main.xml), it then port the Pascal code over to a middle layer that is in Java. Note that it doesn't do 100% conversion to Java but part of the project is in Java.

The full Android (Java) solution get created.
You don't access the Android API directly but by using libraries.

When will it become available?

Can't say for now since am only working on this part time at night and over weekends. It will be a commercial product for sure.

What is my progress?

I'm currently working on the tool's core that allow me to easily add additional controls (TEdit and TLabel I already implemented) together with there properties, events etc. Also to be able to write your own libraries to use the Android API.

Video - Sneak preview 1:

Here I place 2x buttons (TButton) on the Form and write OnClick event handlers for both to display a pop up message.



Running on the phone:

To confirm that it actually do run on your phone and not just in the Android emulator, use this Q-code to download and run the sample on your phone.

Also to tease you more I've included the source code for both Delphi and the generated code (in Test folder).

NOTE: I DON'T TAKE ANY RESPONSIBILITY FOR THE LOST OF LIVE, DAMAGE ETC TO YOUR PHONE BUT ON THAT NOTE YOU CAN TRUST ME SINCE THIS IS A VALID DOWNLOAD THAT WILL NOT KILL YOU OR CONTAIN A VIRUS.

Donation:

As a contractor a donation would be nice since that will help me to spend more time (time = money as a contractor) to work on it.








Monday, June 28, 2010

My Babies...


Franky that is our new boy dogie and Zoe our little girl... cuddling on the couch!


Wednesday, June 23, 2010

For The Love Of C++ Part 2

For the last year I've been programming in C++ on a personal top secret project.
I'm using Visual C++ 2010 with the new C++ 0x language features.

C++ is difficult mostly because it needs to b backward compatible with C but it is also powerful. For me I tend to learn everything and sometimes I say to myself "Nope I will not do it that way" Or "Nope, that is dangerous! Never do that". off course all this comes from experience or reading blogs etc to gain knowledge from others that do have the experience.

For example, many times I read "don't do multiple inheritance" and many reasons why... I tried it myself and yes it does hurt. So yes you see why blogs say that.

On that note its always good for you to try something yourself to learn the advantages/disadvantages etc.... remember that programming isn't just about reading about it but actually doing it... get a project to work on being your own personal project, a project at work or join an open source project.

Monday, April 12, 2010

Slow Death Of The iPhone Platform

Yes your heard right, the iPhone platform is going to die a very slow painful death all thanks to its own maker: Apple

Picture an entrepreneur that got an idea for a new fantastic mobile application, off course that person want to target all mobile platforms to archive the greater market place: Android, Symbian (J2ME/C++ whatever the tool), Blackberry, Windows Mobile/Phone 7 and the iPhone.

So the person might get individual quotes for each platform but because the iPhone is such a close environment the developers that can target that platform will off course charge much more for development so because development for all the other platforms are reasonable they might decide that its then not worth targeting the iPhone... Note that even if they do accept the quote there are still all the issues where Apple reject applications to the AppStore sometimes for every stupid bizarre reasons.

Saturday, April 10, 2010

iPhone Development Just Got Harder

When I look into buying a new phone this year I look at a lot of things (does it have a camera, are there apps available , does it have a nice data plan, does it have 3G and Wifi etc) but as a developer I mostly want to code for it... That is why my current phone is a Windows Mobile device since I can easily use MS Visual Studio.Net with C# without having any other cost.

The iPhone is a great device (like the new iPhone 4G will b even better) but its hard to code for it, a big disadvantage.... You need to buy a Mac, learn Objective C or some other tool (like MonoTouch etc), pay the USD $99.00 per year (that isn't actually very bad if you got the money)

With the release of the new terms and conditions for the iPhone OS 4.0, Apple disallow applications not written in C / C++ or rather Objective C.... Development just got harder!

I just want Apple and everyone to remember, for us developers and companies its about USERS/CUSTOMERS... If we can't develop applications easily because a platform is closed down then its the USERS/CUSTOMERS that will suffer since they will not get the kind of applications that they want.

THE USER / CUSTOMER MUST B MORE IMPORTANT, ALWAY!!

I hope this will change for Apple else I will go for another platform like Android where I can actually use a tool like Java to code or go for Windows Phone 7 where you can use MS Visual Studio.Net 2010.

Friday, March 19, 2010

MWEB Uncapped ADSL Launch Overview

For more than a decade South African internet users wasn't happy with the pricing and level of services for ADSL... ADSL is expensive, you use to buy per GB and monitor your usage all the time to make sure that you don't go over... You don't download anything or like me way back ask a friend from the UK to download software for me then post it on a DVD.

We are jealous with America where there is uncapped ADSL at a very low price, uncapped ADSL on a smart phone (like iPhone 3G)

Yesterday, 18 March 2010 MWEB surprise (or shocked) the ISP market by offering uncapped ADSL service at a very reasonable price.

I phoned the call center (not going thru any other channels as an MWEB employee) and signup within minutes for 4Mbps uncapped ADSL at R539.00 per month.

The speed is fast, being at other providers before, MWEB service is REAL and reliable.

Please visit there website for more information on the different packages available like 384Kbps uncapped ADSL for R219.00 per month.

Note that you also get a free 2GB mailbox, 300 free Wifi minutes that can be used at Mugg & Bean or airports. Other value added service also included like Faxmail.

Saturday, March 13, 2010

Increase Your Existing Language Skills First

This topic is programming related but let me first start with a small story, I am originally Afrikaans but I married a wonderful lady who is English. I could always learn a new language like German / Spanish but I need to improve my existing language skills first, to be able to speak/read/write English... My wife corrects me a lot on this if I say
something wrong... it's a learning process!

The same applies to a programming language, you can learn 100 programming languages but are you productive in them? The languages that I use the most is:
  • C#
  • VB.Net
  • Java
  • C++
  • PHP

and I am still learning new language features etc daily. Some developers are stuck programming in only one language like Java and will never look at another language like C# via different reasons, I agree that you should know more than one language but being productive in them is another story.

Another reason for learning a language is the current market demand, currently in South Africa mainly C# and Java jobs are available, sometimes PHP jobs or other tools (Flash etc) if your looking for example to get a job as a COBOL developer then you will struggle. You need to see what the demand is else you will not get a job.

So going forward look at your existing langauge skills and see how you can improve, do you know how to write a design pattern in your language? Do you know how to use generics in C# or are you just used to doing a "List"? What about other generic features? So my point is, rather learn something new, something that will make you more productive something that you haven't looked at before (maybe how to write annotations in Java? or C# Reflection?)

It gives you a lot of advantages, you're then a more productive developer in the given language and able to find mistakes easily etc.

Tuesday, February 23, 2010

Java Quiz: Array Initialization Answer

Its a difficult answer if you come from a Pascal (Delphi), C or C++ back ground where you had to initialize the array first with default values like 0 before using.

Java automatically initialize all elements in an array to default values, object references become null and primitive integers become 0.

This is in my SCJP exam studies, tricky since I come from a Pascal and C++ back ground.

In C/C++ you get some random data (whatever is in memory at that pointer address). So for them you need to initialize the array before use.

Monday, February 22, 2010

Java Quiz: Array Initialization

Is the following correct? What will the output be?
And PS: Try to figure it out before actually running the code :-)
public class BirthDays
{
static int [] year = new int[100];
public static void main(String [] args)
{
for(int i=0;i<100;i++)
System.out.println("year[" + i + "] = " + year[i]);
}
}

Please give your answer in the comments.

Thursday, February 11, 2010

Microsoft vs Apple War Continue: The iPad

After reading an artical about Bill Gates being unimpressed with the iPad, I see that the whole Microsoft is against anything that comes from Apple - the iPhone for example, they all focus only on there Windows Mobile phones (which got there own problems - more about that in later blog) , no iPod only there Zune device.

The war between Microsoft and Apple (or let me rather say Bill Gates and Steve Jobs) started in the 1980s, all the geeks know the story but let me repeat... Microsoft was doing DOS for IBM and Apple there Apple II etc machines (before the Mac) so it was Apple vs IBM, Apple then released the Mac - first operating system that got a graphics user interface (GUI) - they stole this idea from the Smalltalk system... Microsoft then wrote software (spreadsheets etc) for the Mac, later on Microsoft released Windows and that stole the market. So yeah, Steve jobs wasn't happy with Microsoft (Bill Gates) for steeling there GUI OS idea even if they stole it from the Smalltalk system... actually if you look at this story both of them are wrong.

Over years there was no love between them... Currently for example you need a Mac to write software for the iPhone/iPod Touch/iPad (known forth as the i-Devices) can't do it on a MS Windows machine.

Personally I see this as wrong... We are customers, we don't care about fights, bad feelings etc that companies got against each other... This if for example why Steve Jobs is wrong - his feelings is always in the way of his business judgement... customers are asking for Flash support on the i-Devices but no his got a thing against Adobe.

Give us what we ask for! Give us what we want! If you give us what we ask for / want without all this other crap (that is the only way of expressing it) then your product will grow and you will become more successful then the company X that you got a thing against.

Sunday, February 7, 2010

Blackberry True Push Email

With push email you get email delivered immediately on your phone just like an SMS, most phones say that they support push email but its not actually true push email... just like MS Outlook where all that they do is to check your mailbox every x minutes (like 5/10 minutes) so every time it does a simple send & receive.

The Blackberry support true push email using BIS (Blackberry Internet Services) you can setup email accounts (like your Gmail account) and it get pushed to your Blackberry - there is a lot of detail on how this works but I will not explain it here.

As in previous blog entry you can pay R59 per month (30 days) from your Vodacom airtime which give you unlimited internet access on your Blackberry meaning that you don't pay R2 per 1 MB for internet (3G/GPRS/EDGE) - push email, Facebook and browsing is free.

There are limits, you can't for example download huge emails, emails got a limit size as well etc. I suggest you check with your service provider (Vodacom, MTN) onthese limitations.

Also at work my phone is always on silent, the Blackberry got it nice where if there's a email a little red light flickers - very nice visible notification.

Thursday, February 4, 2010

My Blackberry Experience

Over last weekend I bought myself the Blackberry Curve 8520 smartphone, I always wanted to have a Blackberry since I heard its very good especially with email taken that I spend a lot of time on emails.

I didn't got the device on a contract but as a prepaid package, so I bought it cash together with a Vodacom prepaid SIM card.

With Vodacom you can signup for the Blackberry Internet Service by using your airtime, R59 for 30 days (subtracted from your airtime) gives you unlimited Internet access e.g. browsing, Facebook, Twitter and push email. Note that Skype (VOIP) or any form of streaming will cost you extra since that isn't part of the unlimited Internet package.

For push email you just register your email addresses on the Vodacom portal and get pure push email (I will blog about push email in the future).

For Facebook a little blue envelope will appear if someone sent you a message etc.

The Blackberry Curve uses GPRS/EDGE and Wifi unfortunately no 3G support but for me that is fine since I'm mostly in a office where there is Wifi and yes I'm one of those that don't use my phone while driving.

For me the most to get used to was the little keyboard, I came from my Samsung Omnia i900 and iPod Touch that got touch screens and all of a sudden need to get used to the little keyboard.

If your a developer, please fill in my poll: Do u want C#/VB.Net for Blackberry?

Wednesday, January 27, 2010

Apple's Unveils The iPad

At a special event last night 20:00 South Africa time, Apple's CEO Steve Jobs unveiled the new iPad. I couldn't watch it online since unfortunately Apple didn't broadcast it but I did listen to an audio feed together with some photos from Engadget, Live Gizmodo all from my iPod Touch (on Wifi) while in bed with a stomach bug.

The iPad got multi-touch, very big screen, fast processor, comes in Wifi only, Wifi/3G models etc. For all the details you can read the references below - I'm not going to repeat here. For me it got some advantages / disadvantages:

Advantages:
  • Bigger then the iPhone/iPod Touch so browser is nicer
  • Comes in Wifi/3G models.. if you don't want to wait for the 3G model you can buy the Wifi only model and use a tool like MyFi that broadcast a Wifi signal from 3G (3G -> Wifi).
  • Very fast processor, most of the reviews are happy about how fast it is.
  • iWork: Office like package (try to compare it with MS Office) for word processing, spreadsheets etc. USD $9.99 from the AppStore.
  • AppStore: Buy all existing applications developed for the iPhone from the AppStore and run it on the iPad without modifications.
  • New SDK: New SDK for development of iPad applications
  • Games: Very good graphics, I love playing games on my iPod Touch / wife's iPhone.
  • Keyboard: A physical keyboard that you can connect to the iPad if your not keen on using the on screen keyboard (like me: I dislike typing on the iPhone/iPod Touch).
  • iBooks: New online store where you can buy e-books and read them the iPad.
  • Price: At USD $499.00 (about R3,773.09 base upon the current exchange rate) for the Wifi only model the pricing is very good.
Disadvantages:
  • Its not a PC, you still would require a Mac OS device to write applications for the iPad.
  • No multi-windows, only one application can run at a time... Just like the iPhone / iPod Touch.
  • Base upon new iPhone OS so got the same disadvantages
  • No GPRS - Not everywhere in South Africa there is Wifi or 3G.
  • No webcam build-in or microphone... doesn't see how applications like Skype/Fring will work if you want to do VOIP.
  • Wait: We're going to wait months before its available in South Africa.
So for me: I will not buy one, its got all the same stuff that the iPhone got already and you can phone with the iPhone (and use Skype/Fring), it got 3G and GPRS. I would like to see iBooks and the keyboard for the iPhone but that is something that I can live without.

References:

Tuesday, January 12, 2010

Happy New Year 2010 & My QBASIC Story

Happy New Year 2010 (that is Twenty-Ten :-)

I hope this year is full of joy, fun in your live. I'm having a full year with alot of work and my Java Certification exam in June 2010.

I reguarly visit reddit to see what is new in the programming world... I notice that there is a QBASIC interpreter written in JavaScript available online. By default it runs the Nibbles game (an old classic snake game).

QBasic was the first programming language that I used at the age of 14.. (I'm 28 now) when I was young, inexperience and programming was fun (yes it currently is still fun!) - writing my own dictionary, book library, help me with homework (especially maths) that is where my love for programming started that later became my career (another story how that started).

My dad bought me a old 386 SX, 40 MHz, 2MB RAM, 1.2 GB hard drive that ran MS DOS 6.22 with MS Windows 3.1. I learnt BASIC since it was the only books avialable in the schools library, taught you the old GW-BASIC in a cartoon style... GW-BASIC had line numbers etc where with QBasic it was the first version that didn't hand line numbers, had a proper IDE (no syntax highlighting or code completion yet), proper debugging in the form of breakpoints etc. In the language there was GOTO and GOSUB but mostly for back-ward compatibility with GW-BASIC where you get proper SUBs and FUNCTIONs in QBasic.

Later on I moved over to Library Basic so that I can compile my applications and not give my source away (yes even at that age I was very protective of my source code!)