ya que esta es una de las páginas más populares en los resultados de Google para este tema. Me gustaría contribuir con mi código que está verificando las interfaces disponibles. Funciona en un teléfono Gingerbread que tengo, pero no en mi Galaxy S3.
// DETECT INTERFACE NAME
Log.i("UsbTethering","Detecting tetherable usb interface.");
String[] available = null;
ConnectivityManager connMgr = (ConnectivityManager)connectivityServiceObject;
Method[] wmMethods = connMgr.getClass().getDeclaredMethods();
for(Method getMethod: wmMethods)
{
if(getMethod.getName().equals("getTetherableUsbRegexs"))
{
try
{
available = (String[]) getMethod.invoke(connMgr);
break;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
// DETECT INTERFACE NAME
if(available.length > 0)
{
for(String interfaceName : available)
{
Log.i("UsbTethering", "Detected " + String.valueOf(available.length) + " tetherable usb interfaces.");
Log.i("UsbTethering", "Trying to " + desiredString + " UsbTethering on interface " + interfaceName + "...");
Integer returnCode = (Integer)method.invoke(connectivityServiceObject, interfaceName);
if(returnCode == 0)
{
Log.i("UsbTethering", "UsbTethering " + desiredString + "d.");
return true;
}
else
{
Log.w("UsbTethering", "Failed to " + desiredString + "Usb Tethering. ReturnCode of method " + method.getName() + ": " + String.valueOf(returnCode));
}
}
}
"La respuesta es siempre la misma, las aplicaciones normales no pueden hacerlo, solo las aplicaciones del sistema". - Más exactamente, no hay nada en el SDK de Android para administrar la conexión USB. – CommonsWare
Sí, entonces, ¿cómo logró esa aplicación hacerlo? Puede que no esté en el SDK pero sin duda es posible. ¿Fue un sucio truco? ¿Un exploit? Tal vez fue parcheado en 4.0? –