나는이 간단한 코드를 가지고있어 웹 서비스를 얻는다.UnknownHostException (webservice http-get)
String URL = "http://services.sapo.pt/EPG/GetChannelList";
String result = "";
final String tag = "Data received: ";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button btnSearch = (Button)findViewById(R.id.btnSearch);
btnSearch.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
callWebService();
}
});
} // end onCreate()
public void callWebService(){
HttpClient httpclient = new DefaultHttpClient();
HttpGet request = new HttpGet(URL);
ResponseHandler<String> handler = new BasicResponseHandler();
try {
result = httpclient.execute(request, handler);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
httpclient.getConnectionManager().shutdown();
Log.i(tag, result);
}
이 이미있는 경우 내 매니페스트
<permission android:name="android.permission.INTERNET"/>
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AndroidApp"
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>
URL이 작동하는지 확인하려면 브라우저를 먼저 사용하십시오. –
예 ... 브라우저에 연결되어 있지 않을 수도 있습니다. –
url이 작동하고 브라우저를 확인했는데 인터넷이 연결되어 있습니다. v1.6으로 제작되었습니다. 나는 웹을 검색하고 그것이 매니 페스트에 대한 허가를 추가하는 것을 가리키고 있지만 나는 이미 그렇게했다. – bruno