Archive

Posts Tagged ‘CompactFramework’

Programming for Android

January 15th, 2010 No comments

So I’ve done my first programming for Android phones and thought I’d write a blog post about the experience.

Programming for Android is a bit different from working with the Compact Framework. The abstraction level for the Dalvik applications is somehow high than the Compact Framework application. One difference for example is that there is no main() method to start your application from.

Central for an Android application is its Android Manifest file. This file describes all services and activities available in the application. This is an XML file that helps describe your application to Android, what it’s capabilities are. Each Activity can then be used as an Entry point, but the manifest also describes Services, Content Providers and Broadcast receivers.

What this gives you is a set of loosely coupled components that interact with each other using Intents, that are passed on a system wide message bus. This allows applications interact not only with central parts of the phone, but also with other applications. Which is quite interesting.

Developing in this manner gives you a set of conventions to follow. I feel that they have managed to find a set of conventions that gives direction in the design of the application, but doesn’t confine you.

The SDK also gives you a set of base classes (template method pattern style base classes) that helps you develop common tasks in a standardized way. An example of these are the Task classes that provide threading and scheduling support. I quickly fell in love the the AsyncTask for example.

Android protects the foreground UI thread quite extensively, making these constructs for doing background work important. For example your not allowed to construct or access any UI elements on background threads. This can be handled by using a special Looper construct that effectively divides your Thread code into different parts. One setup part that’s allowed to access, or setup UI components. And one Loop part that does the actual work.

I worked mainly in the Emulator. The emulator feels fast at first, it takes a while to boot up but is quite responsive once booted. That is until you start typing using the computers keyboard. When you do this the emulator feels slow. Apart from a few issues with the emulator loosing “internet connectivity” when my computer Hibernated.

Now it’s time to mention a tool that’s quite helpful when working with Android applications. It’s the adb.exe logcat tool available in the Android SDK. This tool allows you to watch the result of log statements in runtime, and shows stack traces for those errors the occur but you’ve partially managed to take care of (ignored).

This being said there are some things I’m missing when comparing to working with the Compact Framework. For example, working with XML is much easier in the Compact Framework. I hate having to write my own parsing and serialization code, and there are more tools to help me generate code for doing this in the .Net framework.

Also using the HttpClient in the Android SDK is unnecessarily hard. Https works only with some special glue code. And as far as I can tell everyone seems to simply accept any certificate instead of providing support for showing a UI where the user can accept an unknown (self-signed) certificate.

This is all I can think of right now (this is the second time of writing since I had a crash when I tried to post it…). If there are any questions, please ask them. Hopefully they’ll help generate more knowledge about Android development.

Compact Framework checks InvokeRequired for get visible

February 5th, 2009 No comments

Im writing a piece of code in compact framework that is supposed to tear down memory intese controls when they arent visible and then reactivate them when they are visible.

Now I agree that checking visiblity in a worker thread isn’t pretty. but the fact thaty the throw NotSupportedExceptions for a get is quite interesting. A get-operation shouldn’t mutate the state of the object and thus be safe to check from a different thread, right?

Mobilize your Enterprise and Achieve Global Scalability with Windows Mobile and SQL Server Compact

November 28th, 2008 No comments

This Session at tech-ed was held by Rob Tiffany, about how to utilize SQLCe with merge replication to achieve a scalable solution with SQL Merge replication to and from devices.

This is the typical session that I wish I’ve been to 3 years ago. We’re using merge replication to devices In our current product (not the new on though). We’ve had moderate success with it, but Rob’s recommendations could definitely improve our synchronization performance.

In general most of the what Rob recommended is about the setup of replication devices, and the performance of the hardware on which they run. There were also some suggestions of organizing the database. Ill try to summarize.

  • Organize your data across replication servers based on geographical location, it is easier for an SQL server to handle a subset of the overall data based on location. Location is also natural when it comes to mobile devices.
  • Have the replicated databases synchronize their subsets of business hours.
  • Make sure that the database reserves most of the data, but leave some memory left. This is to make sure the database works intensively with memory without thrashing the memory access for the operating systems services. Swapping memory to disk for common operating system services can reduce the performance of the server.
  • Keep as short a span as possible for the subscription timeout date. The faster a subscription times out the less meta-data is stored.
  • Have the hidden system tables run on a different physical disc than the database itself.
  • Having row-level tracking increases performance but can increase the amount of conflicts.
  • Try to keep join-filter depth as low as possible, and reduce the amount of filters. The database structure sets the limits of how good performance you can achieve with merge-replication.
  • Make sure the thread-pool settings equals the numbers of cores of the hardware, this is to avoid thrashing the CPU with alot of thread switching.
  • Try to defrag or rebuild the indexes on the replicators often. A good tool to check for indexing hot spots is the performance dashboard
  • For the IIS have the .dll file used for merge replication located on a separate physical disc.

All in all, alot of suggestions on how to make your merge replication work better on mobile devices and scale across geographical locations.

Mobile Smackdown

November 16th, 2008 No comments

Interesting session indeed. This was the first time that I felt a culture difference between he session hosters and the people listening to the session.

The crowd was somewhat hard to active, and I believe that most of the people whom went to the session didnt realy know what to expect.

Here are a few interesting points I brought with me:

  • HTC Diamond has multitouch support in the hardware but there is no application that uses it
  • There is a Tell Me service that takes a recording and transforms it to text processing the recording on a webservice.
  • MyMobiler is a free alternative to PocketController, Im using this now on my development PC to test it out, it can be downloaded at http://www.mtux.com/
  • Redfly, a laptop like extender for windows mobile phones. Connect your phone and all of a sudden you have a 7″ display and qwerty keyboard. Aswell as VGA output and USB port extensions.
  • FakeCall
  • Dashwire, backup service for your windows mobile phone, complete for pictures, movies etc.
  • GLMaps 3d virtual earth on a phone with accellorator support to detect which angle your viewing it from.
  • Klaxon alarm clock that can be turned off by shaking the phone
  • WIFIRouter; software that turns your cellphone into a WiFi accesspoint that allows internet sharing over the 3G connection.

System.Core full version on compact framework

November 16th, 2008 No comments

This is a bit of a warning, apparently its possible to add a reference to the full framework of system.core to a compact framework project.

The dll gets installed and deployed to a device without any warnings after its been added to the .csproj-file. When run the device crashes, soft reset is the only way out.

We believe that this happened to us when using Resharper’s “Add reference and import” functionality.

Failing genasm.exe due to claimed missing implementation of abstract method

November 16th, 2008 2 comments

I’m focusing on our Windows Client right now, working out how to handle the loading of lists asynchronously.
As a result I’ve just spent a few hours with the following error message:

Error 5 genasm.exe(1) : error There was an error finalizing type . Method ‘ApplyTemplate’ in type ‘xxxxxx’ from assembly ‘xxxx.MobileClient.PocketPC.asmmeta, Version=3.2.2543.1, Culture=neutral, PublicKeyToken=bd562592246cb6f0′ does not have an implementation. MobileClient

To be honest I never did find out why the above error message was displayed. The base-class implements the method the error message says is missing.

However; changing the specific class from public to internal fixed the problem