我有一个android API的问题:如果我看看android API文档,方法isUP()类NetworkInterface存在,但是当我尝试使用它在一个代码,我无法编译我的应用程序。通过查看android引用的库,我意识到这种方法不存在于类中。Android方法NetworkInterface.isUp()没有找到
我确切地说我使用Android 2.2和eclipse Helios。 这是我的代码:
import java.net.NetworkInterface;
import java.net.SocketException;
import android.app.Activity;
import android.os.Bundle;
public class startEssai extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
NetworkInterface n = NetworkInterface.getNetworkInterfaces().nextElement();
n.isUp();
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
有人可以帮我吗?也许被引用的库是错误的?
在此先感谢。 Sandrine Beauche。
oops !!!有效地,我必须使用Android 2.3来查找此方法。 – 2011-01-26 15:47:19