[英]I can't connect internet emulator with android 4.0
I can't connect to the internet on a emulator (api14) with android 4.0. 我无法在Android 4.0的模拟器(api14)上连接到互联网。 But in android2.2 emulator I can.
但是在android2.2模拟器中我可以。
How can I connect to the internet on android 4.0 emulator? 如何在android 4.0模拟器上连接到互联网?
My program connects to sqlserver using the 2.2 emulator but he can't connect using 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);
Do you see Internet indicator icon at top of screen? 您在屏幕顶部看到Internet指示器图标吗? if no, go to settings and make sure Wi-Fi is set to ON.
如果不是,请转到设置并确保Wi-Fi设置为ON。
Starting from Android 4, apps aren't allowed anymore to do network communication in the main (=UI) thread. 从Android 4开始,不再允许应用程序在主(= UI)线程中进行网络通信。 Without seeing your code I can't say for sure, but could this be your problem?
没有看到您的代码,我不能肯定地说,但这可能是您的问题吗?
To test this, you should move your network communication to a background thread and see if it works. 要对此进行测试,您应该将网络通信移至后台线程,然后查看其是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.