我无法在安卓4.0的模拟器(api14)上连接到互联网。但在android2.2模拟器中,我可以做到。
如何在android 4.0模拟器上连接到互联网?
我的程序使用2.2模拟器连接到sqlserver,但他不能使用4.0连接。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bangkok.kohfood"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".KohFoodActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Connection conn = null;
String url = "jdbc:jtds:sqlserver://192.168.1.11:1433/";
String dbName = "koh;Instance=MSSQLSERVER;";
String userName = "bit";
String password = "1234";
String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,userName,password);
发布于 2012-05-21 10:49:31
您在屏幕顶部看到Internet指示器图标了吗?如果没有,请转到设置,并确保Wi-Fi已设置为打开。
发布于 2012-05-21 14:01:57
从Android4开始,应用程序不再允许在主(=UI)线程中进行网络通信。如果不看你的代码,我不能肯定,但这会是你的问题吗?
要测试这一点,您应该将您的网络通信移动到后台线程,并查看它是否工作。
https://stackoverflow.com/questions/10678914
复制相似问题