Smartphones, Tablets, and Mobile Devices Documents

Showing results for 
Search instead for 
Did you mean: 

Building Android Applications for Simple Data Monitoring


This example shows you how to build a native Android application for simple data monitoring.

emulator SCC.png

Application Architecture


    1. Measurement Application - Performs your measurement and publishes the latest data value to a variable.
    2. LabVIEW Web Service - Retrieves the latest data value in the variable and returns it.
    3. Android Application - Periodically calls the web service and plots the latest data value. (Note: the Android application may miss data points if the Measurement Application is sampling faster than the Android Application calls the web service.)

Download Example Code

Simple Data Monitor (LabVIEW Project).zip

Simple Data Monitor (Android Application).zip


Part 1: Measurement Application

LabVIEW VI's can share data between other VI's using shared variables. In this example, we perform a single point acquisition, plot the point to a chart, and publish it to the shared variable.


Part 2: LabVIEW Web Services

LabVIEW Web Services allow any web capable device to access data from your application through any web interface. Your measurement application continually runs in parallel with your web service VI. When the web service VI is called by a web client, it reads the value from the shared variable, generates an XML string, and writes a HTTP response with the data back to the web client.


After you create your web service VI, you must deploy it within the LabVIEW project.


It can then be invoked via URL web request.


Additional Resources:

Web Services in LabVIEW

Web Services FAQ

Part 3: Android Application

Getting Started with Android

Download the SDK

Hello World Tutorial

Developer's Guide

This code snippet contains the core functionality. It first sets up a connection to the URL, configures the XML parser, reads and parses the XML from the input stream, adds the data value to an array of all data values received, and plots the array of values on the chart.

while (!mStop)

// First, open a connection to the machine where LabVIEW is running

URL url = new URL(mURLText.getText().toString());
URLConnection connection = url.openConnection();

// Set resonable timeouts

// Create an XML document builder with the default settings
DocumentBuilder docbuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

// Parse XML from the web service into a DOM tree
Document doc = docbuilder.parse(connection.getInputStream());

// Now, pull out the value attribute of the first channel element
String value = doc.getElementsByTagName("channel")

// Create an array of data to add to the chart. There is only one
// channel of data right now, so just add one point.
ArrayList<Double> data = new ArrayList<Double>();
// Add the data to the chart.

Chris Delvizis
National Instruments
Member Arvont

This example may not work on Windows XP.  After you deploy the Web Service from the LabVIEW project you may get a message that says it was deployed successfully, but if you look in Distributed System Manager 2009, the service won't be running.  This Knowledge Base article gives some insight.

I still couldn't get it to work on XP with LV 2009, so I switched to Vista and LabVIEW 8.6 and finally got it to work.

On the android side, prepare to spend an hour or two getting your environment setup and run the "hello, world" tutorial to make sure you have everything setup correctly.

Member bartoon

Had some problems, typing the URL is quite tricky. You have to type it like this http://XXX.XXX.XXX.XXX:8080/MobileAPI/SampleTemp. The XXX.XXX.XXX.XXX is your IP. Also you have to solve the problem with the comma to make it work in the Use the dot.

Member Burzredion

I can´t deploy it, I'm using LabVIEW 2010 32bits, Win7 64bits and USB-6009. Error message: "Web Services Deployment Failed. You must start the NI Application Web Server before deploying a web service." but NI Application Web Server is started. Some suggestions?

NI Employee

Hey Burzedion, check out this thread on the NI discussion forums: It has a few suggestions you can try.


Chris Delvizis
National Instruments
Member Burzredion

Hi Chris, thanks for your help. I tried to repair LabVIEW 2010 and still having the same problem. I don't know how to subscribe NI Application Web Server. Some others suggestions? Thanks.

NI Employee

Did you try some of the other suggestions listed on the thread? It may be worth posting details about your issue on the thread so an NI applications engineer can give suggestions.


Chris Delvizis
National Instruments
Active Participant D60
Active Participant


I have only one problem. When I want to connect to WebService I got an error on my phone: Connection Timed out

Do you have any idea?

+++ In God we believe, in Trance we Trust +++
NI Employee

It sounds like you have a networking issue. Try typing the URL into your web browser and see if the web service responds. Are you sure the URL and IP Address is correct?


Chris Delvizis
National Instruments
Member arithmetic

Hi, I have a problem with the Webservice.

When I click to run, the labview throws this message: "Error -67301 occurred at NI_WebServices.lvlib:Error Converter (ErrCode or Status).vi"

Do somebody have any idea? The httprequestID's value is 0, its good?

Thanks for help.

NI Employee

Here is a list of error code: Have you deployed the web service?


Chris Delvizis
National Instruments
Member loops

How to slow down the speed that android application calls webservice?


i knew the answer after post this comment. Thank you

Member mayttr

i have that error when i type URL

Access Error: 404 -- Not Found

Cannot open document for: /SmartPhone/SampleTemp
Member arya1

Hi Chris

Thanks for the code. I have an application which would require me to send around 1000 points every 10 to 20 ms to display in a chart in my phone. With web services, what could be the maximum rate of data transfer?



Member welcomeyoulyl


NI Employee

你想改Android程序或者LabVIEW Web Service吗?如果你想学怎么改Android的程序,我推荐你上Android提供的资源:

Joey S.
Senior Product Manager, Software
National Instruments
Member welcomeyoulyl

Thank you for your reply。我出现的问题和arithmetic一样,LabVIEW:  (Hex 0xFFFEF91B) LabVIEW Web Services: Invalid Request ID.不知道是什么问题?

Member irfan.aloha

I can´t deploy it, with Error message: "Web Services Deployment Failed". How can I go ahead