Extending PhoneGap for Visual Studio to Android devices
August 10, 2012 2 Comments
PhoneGap templates for Visual Studio 2010 have been around for almost a year. The templates allow you create a working Windows Phone 7 app using the PhoneGap SDK without having to learn XAML or C#.
There are plenty of examples on how to create a WP7 app with PhoneGap templates so I will not be repeating the steps here. If you are looking for some good tutorials though check out the following links:
Note: Many of the tutorials reference the older PhoneGapStarter.zip file. However, in later releases the PhoneGap templates are using the newer Apache Cordova files. Click the following links to download the project files and to view the Getting Started guide.
Once you have installed the templates into Visual Studio and completed your project you should be able to successfully run your WP7 app on both the emulator and a Windows Phone 7 device.
To get started click the new app button. A dialog box will appear:
My dialog box now looks like this:
Once you hit the Create button your app will appear under the Apps heading on the Dashboard.
Clicking the app name will bring you to a page containing the various builds that have been created. You will get packages for iOS, Android, Windows Phone, BlackBerry, webOS and Symbian. Note though that PhoneGap:Build will not create packages for iOS unless you have purchased a developer account with Apple and have added the correct signing key to your PhoneGap:Build account. See the iOS Developer Program for more details.
To retrieve your app click the Download button below the appropriate package and save the file to your computer. Since I am building for Android I will receive a file with a .apk extension.
Once the item is saved to my computer I can then move the app to an Android mobile device for installation or even upload it to one of the Android marketplaces. To deploy the .apk file to my Samsung Galaxy Tab 2 10.1 Android tablet I will copy the file from my computer to my Dropbox folder.
To install the app click the file on Dropbox to begin downloading it to your Download folder on the device. Once the .apk file is in your folder click it to begin the installation process.
Note: To install apps that do not come from a recognized Android marketplace you will need to make sure that you allow installation of non-Market applications. To do this go to Settings | Applications and click the Unknown Sources checkbox.
Once the app is installed you will see it in your list of Apps. Here is my PhoneGap Hello World app. Pressing the “Say Hello World” button will put “Hello World” into a TextArea tag.
In this article we saw that by building apps with the PhoneGap template in Visual Studio 2010 we are not solely restricted to using the app on a Windows Phone 7 device. With ready-made sources like PhoneGap:Build and Dropbox we can export the finished product to other mobile devices like a Samsung Galaxy Tab 2 10.1 tablet. This gives us flexibility to test our products before we deploy them to an Android Market like Google Play.