Monday, January 27, 2014

Tutorial 5 - Making Progress

This tutorial is as straight forward as the last one.  Simply follow the "Outside of Eclipse" instructions for editing the Main.xml (or whatever you have named it).  The only kink is that you do not need the xmlns:tools or tools lines.

Now you have a progress circle spinning on your app.  Very useful.

Friday, January 24, 2014

Tutorial 4 - Adjusting Our Resources

This tutorial is very straight forward.  Changing the xml resource files is very easy.  Dot42 adds some templates for resource files that attempt to help you edit them.  I think they work fine, except for the menu template.   Use them if you want, or just open them as normal xml files and follow the "Outside of Eclipse" directions.

For the Icons, just follow the "Outside of Eclipse" directions.  although you will need to rename the files.  Remember that with Dot42 the modifiers go on the files and not the folders.

Friday, January 17, 2014

GitHub Announcement

I have just gotten my GitHub repository with the source code for this blog.  The link is here.  feel free to use as you wish.

Tutorial 3 - Changing Our Manifest

One of the strangest (in my mind anyway) aspects of Dot42 is the lack of direct interaction with the AndroidManifest.xml file.  The manifest file is generated from tags placed in your code files.  Unlike the other .xml resource files, you cannot simply copy and paste the code from the tutorial.  This one takes a little work.

The changes I made to the manifest in this project are wider reaching than the couple of changes in the BC Guide.  I made an attempt to match my generated file with the one from the tutorial project.  Even though the project would compile and run just fine without the additions, I thought it was worthwhile to illustrate as much of the manifest options as I could.

To start, I added the Supported Screens section as indicated in the tutorial.  I added an [assembly:] tag that looks like this: [assembly: SupportsScreens(LargeScreens=true, NormalScreens=true, SmallScreens=false, XLargeScreens=true)].  The next part of the tutorial is the min and target SDK section.  As best I can tell, the only way to accomplish this is in the Project->Properties menu.

The rest of the changes I made were aimed at providing explicit translation from the tutorial AndroidManifest.xml file.  This required adding parameters to the [assembly: Application()] tag.  These parameters correspond to the attributes in the <application> section of the manifest file.  I could not find a parameter for android:allowBackup, but the others were fairly self explanatory.

I had to do some searching for the version information.  It seemed that this info would be in the Project->Properties menu along with the SDK options and package name, but thanks to StackOverflow, I found out that there is an [assembly: Package()] tag and that is where versionCode and versionName are located.

The [Activity] tag goes over our activity and I expanded the default to include the Label parameter..  I could not find information of the Name parameter.  Although it is unnecessary now, I included the [IntentFilter] tag and I am glad I did because the implementation has been changed since the Manifest guide was updated on the Dot42 website.  In the guide it looks like actions and categories were members of an enumeration.  Now they are string[].  I like this better, because it allows you to use the strings that you would find in ordinary Android tutorials.

Well, that wraps up the 3rd tutorial.  I admit that this one had me looking up information more than the previous ones.  If I remember correctly, the next one will be a bit easier.

Thursday, January 16, 2014

Tutorial 2 - Creating a Stub Project

This is the first tutorial with an code involved.  For this I simply created a new Dot42 project.  If this is your first time using Dot42, you will need to create a new certificate.  Set the target framework version to 4.0.3, since we will not be supporting much before that.  Funnily enough, I still selected to add the support library.  We will still need that library later.  The default project generation for Dot42 is very minimal compared to Eclipse and a traditional Java app.  I decided to alter things and add a few to make it closer.

The main area this affected was the area was resources.  The first time I tried to use Dot42 resources were the most confusing aspect for me.  it actually led me to leave the project and pursue java programming.  For anyone else that's confused, here is what I've learned.  resources do not need to be in the ridged folder structure as in Java, in fact, they don't need to be in any folder.  What confused me was how to have say, a portrait and landscape version of a layout file.

In Dot42, you accomplish this by adding the modifier to the file, not the folder.  So, instead of having a main.xml file in a layout folder and a landscape version in a layout-land folder; you have a main.xml and a main-land.xml file in any folder you want.  For me, I still put my resource files in a resources folder and divide that up in a roughly Android way.  So in this project I have a Resources folder and in that Drawables, Layout, Values, and Menu folders.

The best part of a translation project like this is that resource files can be copied pretty much exactly.  The biggest thing to keep in mind is to add the modifiers to the appropriate files.

As a side note I had some trouble with the icon resources.  It was my own fault, I downloaded the ic_launcher files from the Busy Coder github, but I saved  the link and not the actual image.  This caused compilation to fail with no error messages.  A very annoying problem to have.  So make sure your image files are valid images.

The one area that I left off was getting the manifest file to look the same.  This is the focus of the next tutorial.

Tutorial 1 - Installing the Tools

For the purposes of this exercise, I will be using Visual Studio 2012.  Dot42 will give you the option to install SharpDevelop, which is also a great IDE.  Someday, when I have time, I might add additional details for SharpDevelop if there are many significant differences.

Installing Dot42 is extremely easy.  Just download it and it will install the Visual Studio plugin and SharpDevelop if you want.  As a note. Dot42 doesn't use emulators, so have a device handy.

Introduction

Welcome to the Busy Coder in Dot42 Blog.  This blog will record my efforts to translate the tutorials and samples from the Busy Coder's Guide to Android Development into C# using Dot42.  I have finished the first few tutorials and have already run into a few issues, but on the whole, I think this can be a resource for people who want to learn more about Dot42 and maybe even learn Android programming.  This is not, however, intended to replace the information in the Busy Coder's Guide.  Please subscribe and get access to the book in order to get full advantage from this blog.  Without the book, I hope this is still a good place to reference how to accomplish certain basic (and maybe advanced) tasks using C# and Dot42.

So, on to the problems.  The biggest problem hit hard in Tutorial #6 with the addition of ActionBarSherlock.  Dot42 cannot handle adding libraries by source, and ActionBarSherlock cannot be compiled into a .jar file.  What this means is that I will not be able to translate these tutorials with much pre-Ice Cream Sandwich compatibility.  I don't think this will ultimately be as big of a problem now that Gingerbread is down to about 25%.