我想从我的android发送数据文件换句话说{我想输入一些数据,如名称性别位置年龄....等等,这在android中然后把这个数据发送到python}这可以是文件发送?或者它必须是数据?!!
答案 0 :(得分:0)
使用此功能尝试Android Scripting,您可以在Android上创建脚本层。
答案 1 :(得分:0)
如果它是一个开放的服务器套接字,那么在Android上只需使用客户端套接字并发送数据。你必须决定数据的格式是什么以及你将如何解析它,但是换向部分是向前的。
// Create a socket without a timeout
try {
InetAddress addr = InetAddress.getByName("java.sun.com");
int port = 80;
// This constructor will block until the connection succeeds
Socket socket = new Socket(addr, port);
} catch (UnknownHostException e) {
} catch (IOException e) {
}
// Create a socket with a timeout
try {
InetAddress addr = InetAddress.getByName("java.sun.com");
int port = 80;
SocketAddress sockaddr = new InetSocketAddress(addr, port);
// Create an unbound socket
Socket sock = new Socket();
// This method will block no more than timeoutMs.
// If the timeout occurs, SocketTimeoutException is thrown.
int timeoutMs = 2000; // 2 seconds
sock.connect(sockaddr, timeoutMs);
} catch (UnknownHostException e) {
} catch (SocketTimeoutException e) {
} catch (IOException e) {
}