2010년 12월 30일 목요일

Android Tethering API (froyo or above)

ConnectivityManager class has tethering API methods but those methods are not visible in SDK.
But tethering methods exists in ConnectivityManager class and they works properly.
I used java reflection the standard java feature.
For using those methods, do as following.

1. Get ConnectivityManager class
Object obj = getSystemService(Context.CONNECTIVITY_SERVICE);

2. Find "tether" method on the object
Method m = obj.getClass().getDeclaredMethod("tether", String.class);

3. Invoke that method: When invoke the method send tethering interface usually 'usb0'
m.invoke(obj, "usb0")

If you want to turn off the tethering connection, you simply invoke the "untether" method in this way.

I hope this information helps you.

댓글 없음:

댓글 쓰기