Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a non-public Tethering API in the <code>ConnectivityManager</code>. As shown above you can use reflection to access it. I tried this on a number of Android 2.2 phones, and it works on all of them (my HTC turns on tethering but does NOT show this in the status bar..., so check from the other end). Below is some rough code which emits debugging stuff and turns on tethering on usb0.</p> <pre><code>ConnectivityManager cman = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); Method[] methods = cman.getClass().getDeclaredMethods(); for (Method method : methods) { if (method.getName().equals("getTetherableIfaces")) { try { String[] ifaces = (String[]) method.invoke(cman); for (String iface : ifaces) { Log.d("TETHER", "Tether available on " + iface); } } catch (Exception e) { e.printStackTrace(); } } if (method.getName().equals("isTetheringSupported")) { try { boolean supported = (Boolean) method.invoke(cman); Log.d("TETHER", "Tether is supported: " + (supported ? "yes" : "no")); } catch (Exception e) { e.printStackTrace(); } } if (method.getName().equals("tether")) { Log.d("TETHER", "Starting tether usb0"); try { int result = (Integer) method.invoke(cman, "usb0"); Log.d("TETHER", "Tether usb0 result: " + result); } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>Please note: this code requires the following permissions to work:</p> <pre><code>android.permission.ACCESS_NETWORK_STATE android.permission.CHANGE_NETWORK_STATE </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload