Yes, i checked the INTERNET permission along with other web-related voices (just to be sure :p ).
Here is the code, it's a bit complicated because originally I wanted to send a string chosen from a list:
- import ketai.ui.*;
- import oscP5.*;
- import netP5.*;
- import android.net.wifi.WifiManager;
- import android.text.format.Formatter;
- import android.net.wifi.WifiConfiguration;
- import java.util.*;
- String IP;
- OscP5 oscP5;
- NetAddress myRemoteLocation;
- KetaiList selectionlist;
- KetaiVibrate vibe;
- ArrayList<String> colorlist = new ArrayList<String>();
- color backgroundcolor = color(0, 0, 0);
- void setup()
- {
- WifiManager wim= (WifiManager) getSystemService(WIFI_SERVICE);
- List<WifiConfiguration> l = wim.getConfiguredNetworks();
- WifiConfiguration wc = l.get(0);
- IP = Formatter.formatIpAddress(wim.getConnectionInfo().getIpAddress());
-
-
- NetInfo.print();
- orientation(LANDSCAPE);
- oscP5 = new OscP5(this,12001);
-
- myRemoteLocation = new NetAddress("10.0.2.3",12000);
- textSize(28);
- textAlign(CENTER);
- vibe = new KetaiVibrate(this);
- loadCountries();
-
- //register for key events(keyPressed currently Broken)
- //registerMethod("keyEvent", this);
- }
- void draw()
- {
- background(backgroundcolor);
- drawUI();
- text("IP: "+ IP, width/2, height/2);
- text(oscP5.netInfo().getHostAddress(),width/2,height/2+34);
- text(oscP5.netInfo().lan(),width/2,height/2+68);
-
- }
- void mousePressed()
- {
- if (mouseY < 100)
- {
- if (mouseX < width/3)
- KetaiKeyboard.toggle(this);
- else if (mouseX > width/3 && mouseX < width-(width/3))
- KetaiAlertDialog.popup(this, "Pop Up!", "this is a popup message box");
- else
- vibe.vibrate(1000);
- }
- else
- selectionlist = new KetaiList(this, colorlist);
- }
- void onKetaiListSelection(KetaiList klist)
- {
- println("sending method started");
- String selection = klist.getSelection();
- OscMessage myMessage = new OscMessage("/test");
- myMessage.add(selection);
- OscP5.flush(myMessage, myRemoteLocation);
- println("sent "+selection);
- }
- void drawUI()
- {
- pushStyle();
- textAlign(LEFT);
- fill(0);
- stroke(255);
- rect(0, 0, width/3, 100);
- rect(width/3, 0, width/3, 100);
- rect((width/3)*2, 0, width/3, 100);
- fill(255);
- text("Keyboard", 5, 60);
- text("PopUp", width/3 + 5, 60);
- text("Vibrate", width/3*2 + 5, 60);
- popStyle();
- }
- //use event framework temporarily
- public void keyPressed() {
- if (key == ' ')
- KetaiAlertDialog.popup(this, "SPACE pressed", "You pressed the <SPACE> key!");
- else
- println(key);
- }
- void loadCountries() {
- String lines[] = loadStrings("countries.csv");
- for (String s : lines) {
- String[] list = split(s, ',');
- colorlist.add(list[0]);
- }
- }
the relevant part is this one:
- void onKetaiListSelection(KetaiList klist)
- {
- println("sending method started");
- String selection = klist.getSelection();
- OscMessage myMessage = new OscMessage("/test");
- myMessage.add(selection);
- OscP5.flush(myMessage, myRemoteLocation);
- println("sent "+selection);
- }
this code gets called when the user selects an element from a list of words generated from a csv file:
- STATI UNITI D'AMERICA,17
- REGNO UNITO,18
- NORVEGIA,2
- FINLANDIA,10
- REPUBBLICA POPOLARE DI CINA,4
- POLONIA,3
- SVIZZERA,3
- LITUANIA,1
- SPAGNA,37
- PORTOGALLO,13
- COLOMBIA,1
- CANADA,4
- SINGAPORE,1
- FRANCIA,59
- CILE,5
- INDIA,2
- AUSTRIA,5
- PAESI BASSI,9
- NICARAGUA,1
- TURCHIA,2
- IRLANDA,3
- SUDAFRICA,1
- MESSICO,1
- REPUBBLICA CECA,4
- MALTA,1
- SLOVENIA,1
- ISRAELE,1
- ARGENTINA,2
- UNGHERIA,1
- LETTONIA,1
- ECUADOR,1
- GIAPPONE,3
- GERMANIA,27
- AUSTRALIA,7
- LIBANO,1
- ESTONIA,1
- DANIMARCA,9
- SVEZIA,10
- BRASILE,10
- CIPRO,1
- FEDERAZIONE RUSSA,2
- GRECIA,1
- BELGIO,11
- COREA DEL SUD,1
that's it. I tried connecting the tablet to the pc with an ad-hoc wifi network and by using a router hosting the wifi spot, but the result is the same.
the device is a samsung galaxy tab 10.1 with android 4.0.4