Using Crossfire 6.0 and Visual Studio to Build Blackberry Applications

Using Crossfire 6.0 and Visual Studio to Build Blackberry Applications

ne dilemma developers face when building applications for mobile platforms is deciding which platform to focus on. In the past, Microsoft developers’ choices were limited to Windows Mobile-based platforms; but AppForge’s Crossfire makes it possible to write mobile applications using Visual Studio and C# or VB.NET that run on any of seven different platforms.

Crossfire 6.0 is the latest version of the product and adds support for the Blackberry platform. Crossfire works as an add-on to Visual Studio 6.0 or any version of Visual Studio.NET. Currently Crossfire supports these platforms

  • Motorola A1000
  • Nokia 9500/9300
  • Nokia Series 60
  • Palm OS
  • Research In Motion (RIM) Blackberry
  • Sony Ericsson P800/P900
  • Windows Mobile-Based Pocket PCs.
Author’s Note: Because AppForge adds support for new platforms periodically, you should check the AppForge Web site for a complete up-to-date listing of actual devices.

With Crossfire, while the statement that your .NET-language programs run on any of the supported platforms is true in the general sense, each platform supports specific functions that?if you use them?will make your application non-portable, so you need to keep that in mind as you plan and develop cross-device applications. This article focuses on the process of developing and deploying a sample application to a Blackberry 7100i device.

There are some limitations to the current release with respect to the Blackberry platform. The most significant is the lack of access to any of the Personal Information Manager (PIM) functions on the device. You also can’t access most of the native Blackberry Java functionality. This will change with the next release (6.5) due out later this year. AppForge is currently developing something they call a “fuser” that provides direct access to all native functions on the Blackberry platform.

You must install a number of external helper applications prior to compiling or deploying to a Blackberry. The most important is the Java Development Environment. For this tool you have two options?you can either install the full development toolset or a reduced runtime version. You’ll probably also need the code-signing tool if you use any of the APIs that must be signed (more on that later).

If you want to test your application on an emulator before deploying to an actual device, you’ll also need a corresponding emulator for each device on which you wish to test. In the case of the Blackberry, you can get freely available emulators from RIM, which support virtually every Blackberry device currently on the market and even some of the older devices. You don’t have to sign applications before deploying them to the emulator.

After you install CrossFire you’ll have access to a number of different utilities that help in creating and migrating applications between different platforms. The list of AppForge utilities includes:

  • Database Converter?convert Microsoft Access Database files to Palm Database format
  • PDB Database Viewer?view the schema and contents of a Palm Database file
  • Font Converter?convert TrueType fonts to AppForge Fonts
  • Font Viewer?view AppForge fonts
  • Graphic Converter?convert Bitmap files to AppForge Graphic (.RGX) format
  • Graphic Viewer?view AppForge graphic files
  • Movie Converter?convert AVI video files to AppForge Movie format
  • Movie Viewer?view AppForge video files

Database Access
AppForge provides its own Data namespace (AppForge.Data) containing classes for performing a multitude of different database functions. The namespace’s classes are arranged in four different functional areas: database access manager, database connections, recordsets, and platform-specific administrators. A Palm database (PDB) library provides a set of non-object-oriented methods for reading/writing PDBs.

Building a Sample Project
AppForge provides a number of sample projects that load when you install the product. Two of these have been tweaked to demonstrate specific Blackberry functionality. For example, the animals database project demonstrates how to store records locally on the device. The sample project uses a PDB file to store a small number of records with five fields. You can load and run the sample on the emulator as shown in Figure 1.

Figure 1. Sample Animals Database Project: The figure shows the Blackberry 7100i emulator running the “animals” database sample project.

Here’s a snippet of code from the animals sample program to create a new empty database:

   dbAnimals_table = afAnimalDB.PDBCreateDatabase(      "animals," iType, iCreator)   If (dbAnimals_table = 0) Then      MessageBox.Show(         "Unable to create Animals database.")      Return False      Application.Exit()   End If   afAnimalDB.PDBCreateTable(dbAnimals_table, _      "animals," "Animal String,Sound String," & _        "NumberOfLegs Integer,Habitat String," & _      "MethodOfTravel String")   Return True

The two parameters in the PDBCreateDatabase call above, iType and iCreator, are integers that hold values needed later to access dynamically created PDB files. You navigate through the database done using well-named method calls such as PDBMoveFirst, PDBMoveToPrevRecord, PDBMoveToLastRecord and such. The Blackberry implementation currently supports only PDB databases.

When you compare the code for adding a new record from the Blackberry version to one for the Palm OS, they look pretty similar.

   ' Blackberry:   Private Sub mnuNewRecord_TrackWheelPress( _      ByVal sender As System.Object, _      ByVal e As         AppForge.Controls.BlackBerry.Control.TrackWheelEventArgs)       Handles mnuNewRecord.TrackWheelPress           CurrentEditMode = modmain.eEditMode.AddRecord           MoveToLastRecord()           Dim frmEditobj As New frmEdit           'Set up the content before showing the form.           frmEditobj.initializeForm()                          frmEditobj.Show()       End Sub      ' Palm OS:   Private Sub btnNewRecord_ClickEvent( _      ByVal sender As System.Object, _      ByVal e As System.EventArgs) Handles btnNewRecord.ClickEvent           CurrentEditMode = modmain.eEditMode.AddRecord           MoveToLastRecord()           Dim frmEditobj As New frmEdit           'Set up the content before showing the form.           frmEditobj.initializeForm()                         frmEditobj.Show()       End Sub

The only real differences are in the name of the subroutine and the arguments. You may need to write more code due to the differences between Blackberry menus and other platforms.

Device Specifics
It’s really not practical to try to force some standard set of behaviors on each device for the sake of portability. This is especially true of the Blackberry with its unique thumbwheel device. You have to build distributable code compiled for each target platform anyway, so you might as well add the platform specific stuff to take advantage of any special features.

In general, the idea is to separate all platform specific code into individual projects?all contained in one Visual Studio solution.

AppForge has a recommended best practices white paper (registration required) that describes how to develop applications that need to target different platforms. When you start a new solution you are prompted to select a design target that sets up the default controls available on that platform. In general, the idea is to separate all platform specific code into individual projects?all contained in one Visual Studio solution. You can then use all common code, such as database access routines, across all the platforms.

When you’re ready to actually deploy an application to a device, you must make a choice on how you want to deliver it. For simple testing it’s easiest to deploy directly to an attached device, but for enterprise-wide deployment you’ll probably want to either push the application using the Blackberry Enterprise System or offer it as an “over the air” download.

For testing purposes in this article, I deployed directly to an attached device, because that’s likely to be what most developers will use during the development process. You can deploy simple applications by selecting a menu option from within the Visual Studio environment. The first time you deploy to a client device you must also deploy the CrossFire Client, which is analogous to loading the .NET runtime on a desktop computer.

The tricky part comes when you must use signed code. RIM devices are based on the Java OS and have the ability to use signed files whenever you use a specific set of APIs. For example, if your application interacts with the local Personal Information Management (PIM) functions you’ll have to sign your application.

You’ll need a set of keys from RIM before you can sign an application. RIM charges an “administration fee” of $100 before they will send you the keys. After you have them you can use their signing tool to sign all your applications. While this might sound painful, it does provide a good level of security, particularly in enterprise environments, because signed applications ensure that applications loaded onto corporate devices are authorized.

Currently, CrossFire has limited “real-time” debugging support. If you’ve developed applications in Visual Studio for Microsoft’s Windows CE environment, you’re used to having access to the full debugger toolset, including breakpoints, single step execution, variable examination, and so forth. CrossFire’s current release does not support any of those features, meaning you have to resort to manually inserting Debug.Print statements or some other “primitive” debugging technique to debug on the device or emulator.

Bottom Line
Although CrossFire 6.0 is a good first step in developing .NET applications for the Blackberry platform, it’s only a first step. You can develop some simple apps?but don’t expect to do anything that needs access to the low level APIs. For that type of support you’ll have to wait for the next version of Crossfire, due out later in the year.


About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist