這現在已經到了我無法忍受的地步!我看到很多人都遇到同樣的問題,但他們的解決方案並不適合我。Android調用REST服務。未找到資源
我想從我的Android應用程序調用REST服務。我對Android的BTW還是個新手。 調用代碼看起來是這樣的:
String httpResult = "";
HttpClient httpClient = new DefaulthttpClient();
HttpContext httpContext = new BasicHttpContext();
String url = myURL;
HttpGet httpGet = new HttpGet(myURL);
HttpResponse response = httpClient.execute(httpGet, httpContext);
//receive response in input stream
InputStream is = response.getEntity().getContent();
//convert the stream into a string
if(is != null){
//call method that will convert stream to string
httpResult = cString(is);
}else{
httpResult = "Error";
}
當我調試的代碼,我看到當編譯器碰到"HttpClient httpClient = new DefaultHttpClient()"
行代碼,並顯示"No Source Found"
屏幕拋出異常。
什麼是例外? – mach
您是否在manifest.xml中設置了Internet權限? – Unii
<使用權限android:name =「android.permission.INTERNET」/>在清單中,在附近標記 –