mysql - how to access string sent from wearable tizen app to android app -
a bit of background: using samsung gear 2, samsung s4 ,eclipse , tizen ide wearable.
i have app on both devices communicates using accessory sdk. on same app, have codes read heartrate. pass heartrate wear app using sasocket.senddata on code below. access string on android app using onrecieve method on shown below.
now, want save heartrate in mysql. how can access string , save mysql?
try { sasocket.setdatareceivelistener(onreceive); sasocket.senddata(channelid,heartrate.tostring()); } catch(err) { console.log("exception [" + err.name + "] msg[" + err.message + "]"); } @override public void onreceive(int channelid, byte[] data) { log.d(tag, "onreceive"); time time = new time(); time.set(system.currenttimemillis()); string timestr = " " + string.valueof(time.minute) + ":" + string.valueof(time.second); string strtoupdateui = new string(data); system.out.println("strtoupdateui : " + strtoupdateui); heartrate =strtoupdateui; final string message = strtoupdateui.concat(timestr); final helloaccessoryproviderconnection uhandler = mconnectionsmap.get(integer .parseint(string.valueof(mconnectionid))); if(uhandler == null){ log.e(tag,"error, can not helloaccessoryproviderconnection handler"); return; } new thread(new runnable() { public void run() { try { uhandler.send(helloaccessory_channel_id, message.getbytes()); } catch (ioexception e) { e.printstacktrace(); } } }).start(); }
first of, great have come far in gear app development i.e getting provider , consume side apps communicate. of hardwork done. assume have heartrate data in heartrate variable heartrate =strtoupdateui;
what can next create method "saves" data . following steps might help.
- create mysql data base , details. can download wamp , install on local machine
- create database , table hold heartreate data
- your android code might not able directly save data mysql database, need write web application (a simple mysqlhandler) written in dynamic web app dev language of choice this.
- from android code, make web request , post heartrate data mysql web handler inserts data mysql.
there tutorial on how build phpbased mysql handler here , save data android. refer stackoverflow answer .
v.
Comments
Post a Comment