1
내가 내 활동의 코드 조각이 거부로드 파일 - 연결이
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView txt=(TextView)this.findViewById(R.id.lbl);
try {
URL url = new URL("http://localhost/test.json");
URLConnection urlconnection = url.openConnection();
long l = urlconnection.getContentLength();
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
StringBuffer buffer=new StringBuffer();
while ((line = in.readLine()) != null)
{
buffer.append(line);
}
in.close();
System.out.println("bufer="+buffer.toString());
txt.setText(buffer.toString());
} catch (Exception exc) {
exc.printStackTrace();
}
}
(I 에뮬레이터에서이 시작) 내가 WAMP 서버를 가지고
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test_android.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".test_android"
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>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
처럼 내 매니페스트 보인다 내 www 디렉토리에 test.json하지만 항상 연결이 잘못되었습니다. 뭐가 잘못 되었 니 ? 자세한 내용은 다음을 참조하십시오 : 당신의 URL에
로컬 호스트에 컴퓨터가 Android-Device/Emulator의 로컬 호스트가 아닙니다! –