10

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.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Kristian Damian
  • 1,360
  • 3
  • 22
  • 43

3 Answers3

7

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:

  1. From your computer, execute:

    ./adb shell netcfg usb0 dhcp

  2. 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

UdayaLakmal
  • 4,035
  • 4
  • 29
  • 40
  • 1
    How do you "activate USB Tethering" on the Windows side? – Michael Jun 25 '13 at 20:08
  • 1
    Recap: *1st step:* setup a new network interface on your Android device called `usb0` (`$ adb shell netcfg usb0 dhcp`); *2nd step:* select the option *USB Tethering* in the Android preferences; *3rd step:* connect the Android device to the Windows machine; *Windows side:* You should able to see a new network interface (usb), now you just need to *bridge* that interface with main interface connected to internet - so that internet is shared from one interface to the another. – Ryan Amaral Jul 31 '21 at 15:22
3

I know this comes quite late, but it seems no real solution has been found yet, and this might help fellow readers:

As I could not find any solution myself, I have developed an app that offers Reverse Tethering for unrooted Android devices running Android 4.0 or higher. All major desktop operating systems are supported.

The app is available on Google Play: https://play.google.com/store/apps/details?id=com.floriandraschbacher.reversetethering.free

FD_
  • 12,947
  • 4
  • 35
  • 62
  • [Reverse Tethering Server Download](http://fdmobileinventions.blogspot.com/p/reversetethering-server.html) – tchelidze Nov 03 '16 at 16:15
1

Maybe you could integrate reverse tethering tools tools into your app

Clinton Ward
  • 2,441
  • 1
  • 22
  • 26