I need to send a few strings from a java project (Windows or Ubuntu) to an Android device via WiFi means. I found a few sources on how to send files from Android device to Android device but I didn't find anything cross platform. Can someone suggest me a way to do it, or a lead about where to look ?
I am open to alternate methods, but as always the simplest the better.
Thanks in advance.
I would write a simple REST web service for the android client to check. That way if you wanted to for whatever reason you could move it to the cloud and do it remotely. That is probably the simplest way I can think of as well.
I would suggest send it through TCP connection.
Because Both Java and Android have ServerSocket class and Socket class.
You can set your computer to be host by using ServerSocket and your Android device to be client by using Socket.
Then after connection, you can use getInputStream() and getOutputStream() methods of Socket to transfer data, including Strings, Objects and even Files with suitable combination of FileInputStream,ObjectOutputStream etc.
Related
I want to build a sniffer in Android and one of the approaches that was proposed was a loop-back VPN.
The issue with this approach is that all the communication with the outside world will be done through a protected socket and in Java I still cannot sniff low level TCP information from that socket.
For example, I cannot find out when exactly an ACK was received for data that was sent from the phone. Am I missing something or is this approach simply not suitable for a proper sniffer?
You won't be able to get ack information and other low level info using an Android VPN as this data won't be exposed through Java sockets.
An alternative is to utilize a native sniffer (TCPdump is one example, and an Android port already exists), execute it as root from your Java app and then retrieve its output in your app
I'm developing an Android application and want it to connect to an OpenVPN Server.
Since Android 4.0 there is a VPNService class. This class however needs to intercept all the network packets(and require special permissions) because it is apperently running on the Internet Protocol. However as far as I understand, OpenVPN is running on-top of TCP or UDP(my server is configured to use UDP). I only need to tunnel the traffic from my own application through the VPN tunnel.
Shouldn't it theoretically be possible to avoid this(because I don't need to intercept all the traffic, but only the UDP-OpenVPN packets targeting my application)?
Do you know of a library for Android that fulfills my needs?
If not, would it be possible to implement the OpenVPN protocol in Android on-top of UDP without the need of the VPNService class?
I found the follwing project: ics-openvpn. However it also uses the VPNService class and intercepts all the packages.
Sure, you can theoretically do UDP/OpenVPN in userspace/inside your app. But you would need to implement the whole TCP/IP inside your app since you need to emulate the whole VPN stack.
For a one app VPN like solution you are probably much better of using a SOCKS/HTTP proxy etc. library.
You need to use VpnService for creating an application of OpenVPN which takes ovpn file as input for configuration on client side like OpenVPN Connect. So any person can change configuration according to their need. Also, you have to configure the server for OpenVPN. Take server of AWS EC2 or any other. While in configuring VPN on server side follow this link.
I need to make a troubleshooting tool in java
From the java code, I need to communicate with tethereal (linux commands) to help me generate a .pkt file. The .pkt file will contain all the contents of the communication that took place between the client and the server- i.e. all the packet communication between the client and server.
how should I do that?
Do you know WireShark? That is a cross-platform Network Packet Capturing application.
The idea is that it captures all packets (TCP and UDP) that passes one network device (eg: WiFi card) and you apply a filter on the port that your application uses, and eventually an IP address. Very useful tool.
If you really need to do it in java you can use http://jnetpcap.com/ which is a wrapper for libpcap which works similar to tethereal.
So I am trying to stream a webcam feed from my computer to my android phone. I am using a simple forwarding server to connect the two so that I don't have to worry about home network IP firewalls ect. I am using FMJ to capture the video feed and was thinking rtsp protocol would be best because android supports reading it. My problem is I dont know how to forward the information via the server, is it as simple as forwarding UDP packets? all programs involved are implemented in java btw.
Use Netty. It is very easy to create an RTSP server with this library. For hints see the sources here.
Or you can port my library which is written in C#
http://net7mma.codeplex.com/
CodeProject article # http://www.codeproject.com/Articles/507218/Managed-Media-Aggregation-using-Rtsp-and-Rtp
I need to connect to a http server from a phone and play a movie while downloading. I understand that you can simulate this using multiple players (Manager.createPlayer(...)) in J2ME but I dont know how.
Thanks
I just want to suggest some possible approach. But, these methods also depends on device's implementation of MMAPI.
Use RTSP protocol instead of HTTP. It needs server side support
Create new DataSource class which downloads video data by using socket
Get video data by using socket and append it to file. While downloading it pass file data to MMAPI as file:/// protocol