- What you'll need for your application
- Step 1. Create a Mobile Cloud application on Bluemix
- Step 2. Deploy the BlueList NodeJS application to Bluemix
- Step 3. Configure the front-end in the Bluelist sample
- Step 4. Configure the back-end in the Bluelist sample
- Step 5. Run the mobile app
- Step 6. Check your data on the cloud
- Downloadable resources
- Related topics
Build an Android app using Cloudant NoSQL DB and Push Notifications on Bluemix
Store, delete, update, and query objects stored in the cloud
Editor's note: This tutorial is an update to "Build an Android app using the IBM Mobile Data for Bluemix cloud service" originally published in February 2014. The application code has been updated, but the procedures described in the article remain the same.
You may already know about some of the benefits of Bluemix, IBM's open platform for developing and deploying mobile and web applications. The many pre-built services in the mobile solutions in IBM® Bluemix™ make it easy for developers to build and enhance applications.
Tutorials in this series show you how to add cloud-based services to your apps. In this tutorial, we'll cover the steps to build an Android application using the IBM Cloudant NoSQL DB service on Bluemix.
Have you ever gone to the grocery store and forgotten the exact ingredient your spouse needed for that fabulous soufflé recipe? Or the lunch box dessert the kids had requested for the next day? What if they all could enter their requests into a shared grocery list, and you could receive push notifications alerting you to the updates?
Enter the BlueList application. It’s a simple app that uses Bluemix services and will get you started writing your own (more complex) apps in no time! This tutorial shows you how to start with an Android application and add the Cloudant NoSQL DB service to store, delete, update, and query objects stored on the cloud. (A future tutorial will show you how to add the Push and Node.js Cloud services to your application so you can get notifications when the grocery list is updated, and so the list can be refreshed on all devices when one of the devices updates the list in some way.)
“This simple app uses Bluemix services and will get you started writing your own (more complex) apps in no time. ”
What you'll need for your application
- Familiarity with Android development
- An Android development environment. We used Eclipse with ADT, but feel free to use your preference
- The Bluelist sample code (click the button above) that includes the front-end and back-end code used in this tutorial.
- A Bluemix account to use the Bluemix services
Step 1. Create a Mobile Cloud application on Bluemix
- Log in to Bluemix.
- Click MobileFirst Services Starter under Boilerplates in the Bluemix catalog.
- To create an app, enter an app name, host name, and domain (use the defaults for the other options). Click Create.
- After you create the application and it has finished staging, it appears in your console. Click your new application to go to its overview page. You will find a Node.js runtime as well as other services running on Bluemix.
Step 2. Deploy the BlueList NodeJS application to Bluemix
- Clone the sample code to local and download Cloud Foundry CLI.
- Open your local folder where you cloned the sample code. The bluelist folder has the front-end code and the NodeJS folder has the backend code.
- Open the NodeJS folder and update the manifest.yml file according to the Bluemix app and host names that you just created. In this example, my Bluemix app name is shenyBluelist:
- Run the following cf commands to update the manifest.yml file on
Bluemix and restart the application.
cf api https://api.ng.bluemix.net cf login cf apps cf push -f manifest.yml
Step 3. Configure the front-end in the Bluelist sample
- Download Android Studio.
- Open the front-end project folder, bluelist in Android Studio.
- Update the bluelist.properties file located under the assets folder with your Bluemix application information. You can find the route and APPID information by clicking MOBILE OPTIONS on your Bluemix application overview page.
Step 4. Configure the back-end in the Bluelist sample
- Open the Mobile Client Access service for your Bluemix application. Choose Customer Configure (you can also choose Facebook authorization and Google authorization) to configure authentication.
- Click Edit. Use
customAuthRealm_1for the Realm name and your Bluemix application route for the URL. Save your configuration. (The User Yotem with password 456 is hard coded into the sample and will authenticate automatically.)
Step 5. Run the mobile app
Build your Android App and run it on your Android device or simulator. Add some items to the To Do List of your app. Remember to pull down the screen to sync the app with the database on the cloud.
Step 6. Check your data on the cloud
In Bluemix, select the Cloudant NoSQL DB service and click the Launch button to open the Cloudant dashboard.
Go to the todosdb database.
The items are already synced to the database.
Developing this app using the Cloudant NoSQL DB service should give you a sense of how easy it is to consume and integrate mobile data capabilities using Bluemix!
- The Cloudant NoSQL DB service
- Modernize Java apps with IBM MobileFirst on Bluemix
- Extend an Android app using the IBM Push Notifications service