Recently, Microsoft added built-in support for Android in Windows Azure Mobile Services. This makes the lineup of leading mobile platforms complete: Android, IOS and Windows Phone 8.
In this blog post it will be shown how a mobile service can be started and how to make a sample Android app communicate to it.
Note that the blog post of Miranda_Luna has been used as an inspiration for this blog post.
You can find Miranda_Luna’s blogpost over here.
- A Windows Azure account
- Windows Azure Mobile Services (http://www.windowsazure.com/en-us/home/features/preview/ )
- Create an Android mobile service.
- Set up the sample Android application
- Verify data.
Create an Android mobile service.
Navigate to the management portal on http://manage.windowsazure.com
Click on New -> Compute -> Mobile Service -> Create
Specify a URL (Name of your mobile service), database and region. Click on the arrow at the bottom.
In this example I will use an existing database, but you can easily create a new database by selecting the second option in the dropdown menu.
In the next screen, specify the credentials to the database and click on the check mark at the bottom.
After a while, the mobile service is added and ready for use.
Click on the name of the mobile service and on the “ANDROID” tab.
Click on “Create a new Android app”.
The Android SDK is needed to load the sample application. If you don’t have the SDK, click on “Install the Android SDK”. You will be redirected to the Android developers website.
Click on “Download the SDK”.
Here your can accept the disclaimer, select your preferred target platform (32 or 64 bits) and click on “Download the SDK ADT Bundle for Windows” (the package is approximately 400MB).
After the SDK installation is complete, navigate back to the management portal and click on “Create TodoItem Table”.
A table in Windows Azure SQL Database is created, which we will use in the verification step to check the data.
Set up the sample Android Application
Click on “Download” in the third step and follow the instructions that are shown below the button.
On first time use, the following message is shown, since there are no virtual devices. Click on “Yes”.
Select “Launch a new Android Virtual Device” and click on “Manager…”.
Choose a name for the virtual device and specify the type of the device.
Depending on your system’s hardware you may need to tweak the value of RAM to prevent the following message to show up:
When you ignore this message and try to run the project, you might get a runtime exception regarding memory consumption.
Run the project and click on the project name (C3PO in this example).
The sample application is loaded. Specify a ToDo item and click on “Add”.
The item will be added to the SQL database in Windows Azure, using the mobile service defined earlier.
After having added the item, it will be listed. Check the item to mark it complete. It will disappear from the ToDo list.
Navigate back to the management portal and click on “SQL DATABASES”.
Select the database and click on “Manage” at the bottom of the screen.
You will be redirected to the SQL Database portal.
Fill in your credentials and click on “Log on”.
In the portal, click on “Design”.
Click on the table which has the same name as the mobile service defined in the first step and click on “Edit”.
Click on the “Data” tab.
As is shown, the item that has been created in the sample Android application is listed. Depending on whether the item has been checked, the complete value is set to “True” or “False”.
With the addition of built-in support for Android in Windows Azure Mobile Services, Microsoft offers the opportunity for developers to set up a communication channel between their Android apps and Windows Azure SQL Database.
This can be realized in the management portal UI with little effort. In this way, the developer is able to enhance his/her focus on the functionality of the app.