Geolocation and Osc Message


i try to create a programm in Java which sends geolocation( longitude, latitude) from Android to PC via oscP5 library. Based on AccelerometerData example i made this code but my problem is that when i run the code in Java Mode on PC and then pushing a button on my phone’s App to send my longitude and my latitude, they appeared in the Console down pn the window of the Programm…My target is to make them appeared in the interface Window of Java Mode after i run it…Just the example…

Please share the code that you have.


This is the code in Java mode that i run in the PC…I 've got the outpout in the console but not in the interface window that appears after i run the code…

import ketai.sensors.*;
import ketai.ui.*;

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress remoteLocation;

double longitude, latitude, altitude;
KetaiLocation location;

void setup() {
textAlign(CENTER, CENTER);

oscP5 = new OscP5(this,12000);
remoteLocation = new NetAddress("",12000);

void draw() {
    text("Latitude: " + latitude + "\n" + 
      "Longitude: " + longitude + "\n" + 
      "Altitude: " + altitude,  -300, -100, width, height);  


void oscEvent(OscMessage theOscMessage) {
  if (theOscMessage.checkTypetag("fff"))  // 6
    latitude =  theOscMessage.get(0).floatValue(); // 7
    longitude =  theOscMessage.get(1).floatValue();
    altitude =  theOscMessage.get(2).floatValue();
void onLocationEvent(float _latitude, float _longitude, float _altitude)
  longitude = _longitude;
  latitude = _latitude;
  altitude = _altitude;
 println("lat/lon/alt: " + latitude + "/" + longitude + "/" + altitude);

You have already set the textAlign to CENTER, CENTER. It would be easy (and it should work) to have

text("Latitude: " + latitude + "\n" + 
      "Longitude: " + longitude + "\n" + 
      "Altitude: " + altitude, width/2, height/2);

By the way, why are you using negative numbers in your text function? You are taking into account surface area that is not shown in your sketch.



i use negative numbers because the text did not show up in the interface for a reason…Anyway now it appears in the window display after i run the code but with zero values in the longtitude,latitude and altitude but i dont know why. In my andoid app they are appeared correct but in the PC (Java mode) it gets zero values.

As you can see in the picture bellow in the console there are the longtitude, latitude but in the window after running the code there are zero values.

Put the line above also in the oscEvent(). Are you using this code for both your Android and your PC?


Still the same problem… Yes i run this code both in my Android and my PC.