I'm developing an enterprise app in PhoneGap, and I want to work offline with some data, and through a plugin (with code written in Java) send the processed data back over the LAN Network (when this were detected), but I need some code samples to create a reverse tethering without rooting the device nor using external apps.
I'm trying to avoid creating a local component in the windows machine, I want to send the data directly using REST commands.
Any code samples or suggestions are welcome.
Have you tried this simple solution
For Windows: Install USB drivers from Android SDK Connect USB cable and activate USB Tethering. You should see on linux or windows a new network interface.
On windows, Bridge the 2 network interfaces
Setup usb0 interface of your phone. You have two options:
From your computer, execute:
./adb shell netcfg usb0 dhcp
Or in a terminal on your phone, type:
su netcfg usb0 dhcp
You should now be able to connect to Internet on your phone using your computer’s Internet connection. http://acetips.wordpress.com/2011/10/07/reverse-usb-tethering/ and http://blog.mycila.com/2010/06/reverse-usb-tethering-with-android-22.html
for run adb command from your android application you could use
String exeeCmd = "netcfg usb0 dhcp";
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(exeeCmd);
} catch (IOException e) {
e.printStackTrace();
}
apply required permitions