android


Upload sensor data from Android device to remote host


I want to develop an Android application that satisfies the following specifications:
Record data from a sensor (for example the accelerometer) at an
approximate rate of 10-30 Hz.
Upload this raw data to a remote server (for example using TCP
sockets).
The user interface should be minimum, just a pair of buttons to start
or stop the recording and transmission of the data.
All the process should be unnoticeable for the user and keep working
when the screen goes off for several hours.
Battery life is not critical (it should last several hours).
Vision: I would like to analyse in quasi-real time the sensor measurements of a group of users without their intervention (apart from starting the application).
After some research, I could manage to perform these tasks separately and inefficiently. I've tried classes such as Service and IntentService, SensorEventListener, etc. I don't know if I should use Thread, Service or IntentService for each task. Specifically, I have serious problems to communicate them.
My questions:
What class(es) do you recommend to use in order to solve this
problem?
What task should be done on each of them?
If the tasks are performed in different entities (threads, services,
intentservices, etc.), how should I intercommunicate them (I'm
thinking about the recording and uploading tasks)?
I am asking for the best-practice structure to solve my problem. You do not need to go into details in terms of developing/coding the solution.
Thank you very much and feel free to ask if something is not clear enough.
David
UPDATE:
After some more research and thanks to DROIDcoder, I manage to design a skeleton for my app:
Main UI: Activity object presenting two buttons (start/stop) that
will launch a Service with the usual startService/stopService methods
Background: Service object
Awake when screen goes off: the service requests a power lock in onCreate() and releases the power lock in onDestroy(). Find more info here: https://developer.android.com/training/scheduling/wakelock.html#cpu
Log sensor values: implement SensorEventListener in the Service as usual
Upload sensor values to server: use AsyncTask in the service as described here: How to use AsyncTask
Data formatting and transmission: use GSON library + HttpClient as described here: How to send POST request in JSON using HTTPClient?
Testing: use the website http://www.jsontest.com/ to test the JSON queries
As this is only a proposition, I add it as an edition. I will post a detailed answer when the whole system works.
The questions remains: can you think about a better design for the application?
Thanks again!
here are my suggestion
Upload this raw data to a remote server
You can use JSON parsing for server communications. you will use AsynTask(Background Thread) for background data uploading
All the process should be unnoticeable for the user and keep working when the screen goes off for several hours.
You should use services for background long term processing
Finally what I have done:
Issue 1: record data from a sensor on the background for a long period of time.
Solved using the class Service to initialize the sensor and listen for callbacks.
Issue 2: communicate the Activity class holding the UI with the Service class.
Solved using the startService(Intent myMessage) method from the Activity class combined with a switch in the onStartCommand() method from the Service class to classify the message.
Issue 3: communicate the Service class with the Activity class.
Solved registering a custom BroadcastReceiver in the Activity and sending Intents from the Service. I've used it to update a progress bar (in the Activity) during the file uploading (in the Service). An exceptional tutorial can be found here.
Issue 4: upload data to a remote server.
Solved using AsyncTask inside the Service like in this site.

Related Links

Crash on passing large sets of data through intents - is there a size limit on the extras bundle?
Reading json from android internal storage error
Let a user delete a imageview
android support libraries causing errors with legal and valid methods
Why won't the BroadcastReceiver work?
EditText new “row” after 25 characters
SQLite doesn't insert values
How to delete the Existing Records in table and insert new Value in sqlite?
After completely close the app, unable to receive notification from gcm
override empty method in custom view and handle it in MainActivity
ClassNotFoundException: Of Module inside a library project's AAR file
Android: java.lang.NullPointerException at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:490)
How to set time range using seekbar
Rendering Problems on android studio: the following class could not be instantiated
Programmatically setting icon to navigation drawer menu item using drawable resource is always black in Android
DSP (Digital Sound Processing) with Android Media Player

Categories

HOME
batch-file
google-app-engine
spark-streaming
awk
wakanda
apache-jena
datastore
obfuscation
socket.io
big-o
gembox-spreadsheet
android-json
banner
barcode
fabric.io
ibeacon-android
heap
pega
plink
scrolltop
smartclient
nodemcu
asp.net-core-webapi
asciidoctor-pdf
cgbitmapcontext
named-entity-recognition
visual-studio-extensions
ntp
alm
mustache
turfjs
angularjs-material
fstream
papaparse
gnat-gps
installshield-le
openwhisk
indy10
processwire
raft
openalpr
dm-script
android-augmented-reality
bc
vmware-fusion
laravel-elixir
android-softkeyboard
softmax
tcc
monkey-testing
double-click
getchar
cnc
spring-integration-sftp
globalize
corruption
pair-programming
qtranslate
azure-cli
java-bytecode-asm
truezip
lsyncd
flyout
objectscript
slackware
cubism.js
stream-processing
exim4
spring-retry
vhosts
computer-architecture
mod-proxy
pyobjc
entity-framework-4.3
dot.js
code-documentation
addressing-mode
sip-server
sql-scripts
spy++
drupal-nodes
gwt-openlayers
artemis
gtm-oauth2
ie8-compatibility-mode
rolify
cmmi
traceability
windows-98
apache-abdera
bjyauthorize
joomla3.1
curb
web-farm
xcode3.2
rmiregistry
xcelsius
binomial-heap
cfwindow
tui
escrow

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App