- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我构建了这段代码来从 URL 获取 XML我使用了 AsyncTask,当到达 getInputStream() 点时,半身应用程序仍然崩溃
重点是我想从 url 获取 XML 作为字符串。
我尝试不使用 AsyncTask,但应用程序仍然崩溃
我尝试将 GetXML() 函数放在 AsyncTask 之外并从 AsyncTask 内部调用,但仍然崩溃。
我尝试将 GetXML() 函数放入 AsyncTask 中并从 AsyncTask 中调用,但仍然崩溃。
有谁知道是什么原因以及如何解决吗?谢谢
package com.asmgx.test15.app;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AsyncTaskRunner runner = new AsyncTaskRunner();
runner.execute();
}
private class AsyncTaskRunner extends AsyncTask<String, String, String> {
private String resp;
private void GetXML() {
try {
URL url = new URL("http://api.androidhive.info/pizza/?format=xml");
URLConnection conn = url.openConnection();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputStream is = conn.getInputStream(); // CRASH HERE
Document doc = builder.parse(is);
}
catch (MalformedURLException e) {
}
catch (IOException e) {
}
catch (ParserConfigurationException e) {
}
catch (SAXException e) {
}
}
@Override
protected String doInBackground(String... params) {
publishProgress("Sleeping..."); // Calls onProgressUpdate()
// Do your long operations here and return the result
//int time = Integer.parseInt(params[0]);
// Sleeping for given time period
GetXML();
resp = "Slept for 25562 milliseconds";
return resp;
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPostExecute(java.lang.Object)
*/
@Override
protected void onPostExecute(String result) {
// execution of result of Long time consuming operation
//finalResult.setText(result);
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onPreExecute()
*/
@Override
protected void onPreExecute() {
// Things to be done before execution of long running operation. For
// example showing ProgessDialog
}
/*
* (non-Javadoc)
*
* @see android.os.AsyncTask#onProgressUpdate(Progress[])
*/
@Override
protected void onProgressUpdate(String... text) {
//finalResult.setText(text[0]);
// Things to be done while execution of long running operation is in
// progress. For example updating ProgessDialog
}
}
}
这是 Logicat 错误
07-04 04:49:53.433 1850-1863/com.asmgx.test15.app E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.asmgx.test15.app, PID: 1850
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity.GetXML(MainActivity.java:44)
at com.asmgx.test15.app.MainActivity.access$100(MainActivity.java:25)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:68)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity.GetXML(MainActivity.java:44)
at com.asmgx.test15.app.MainActivity.access$100(MainActivity.java:25)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:68)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity.GetXML(MainActivity.java:44)
at com.asmgx.test15.app.MainActivity.access$100(MainActivity.java:25)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:68)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
07-04 04:49:56.643 1850-1863/com.asmgx.test15.app I/Process﹕ Sending signal. PID: 1850 SIG: 9
07-04 04:50:31.313 1899-1899/com.asmgx.test15.app W/ActivityThread﹕ Application com.asmgx.test15.app is waiting for the debugger on port 8100...
07-04 04:50:31.363 1899-1899/com.asmgx.test15.app I/System.out﹕ Sending WAIT chunk
07-04 04:50:31.393 1899-1905/com.asmgx.test15.app I/dalvikvm﹕ Debugger is active
07-04 04:50:31.583 1899-1899/com.asmgx.test15.app I/System.out﹕ Debugger has connected
07-04 04:50:31.583 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:31.793 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:32.073 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:32.273 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:32.473 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:32.673 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:32.883 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:33.083 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:33.283 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:33.483 1899-1899/com.asmgx.test15.app I/System.out﹕ waiting for debugger to settle...
07-04 04:50:33.683 1899-1899/com.asmgx.test15.app I/System.out﹕ debugger has settled (1365)
07-04 04:50:46.343 1899-1899/com.asmgx.test15.app D/gralloc_goldfish﹕ Emulator without GPU emulation detected.
07-04 04:50:54.343 1899-1914/com.asmgx.test15.app D/dalvikvm﹕ GC_FOR_ALLOC freed 215K, 9% free 3170K/3452K, paused 46ms, total 46ms
07-04 04:50:57.773 1899-1914/com.asmgx.test15.app W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xb1ab6ba8)
07-04 04:51:04.553 1899-1914/com.asmgx.test15.app E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.asmgx.test15.app, PID: 1899
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity.GetXML(MainActivity.java:44)
at com.asmgx.test15.app.MainActivity.access$100(MainActivity.java:25)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:68)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity.GetXML(MainActivity.java:44)
at com.asmgx.test15.app.MainActivity.access$100(MainActivity.java:25)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:68)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity.GetXML(MainActivity.java:44)
at com.asmgx.test15.app.MainActivity.access$100(MainActivity.java:25)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:68)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
07-04 05:15:28.973 2141-2141/com.asmgx.test15.app D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
07-04 05:15:31.803 2141-2141/com.asmgx.test15.app D/gralloc_goldfish﹕ Emulator without GPU emulation detected.
07-04 05:15:33.073 2141-2154/com.asmgx.test15.app W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xb1ab6ba8)
07-04 05:15:33.133 2141-2154/com.asmgx.test15.app D/dalvikvm﹕ GC_FOR_ALLOC freed 202K, 8% free 3183K/3452K, paused 43ms, total 43ms
07-04 05:15:33.173 2141-2154/com.asmgx.test15.app E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.asmgx.test15.app, PID: 2141
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.GetXML(MainActivity.java:51)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:72)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:40)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.GetXML(MainActivity.java:51)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:72)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:40)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: getaddrinfo failed: EACCES (Permission denied)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.android.okhttp.internal.Dns$1.getAllByName(Dns.java:28)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:216)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:122)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:292)
at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.GetXML(MainActivity.java:51)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:72)
at com.asmgx.test15.app.MainActivity$AsyncTaskRunner.doInBackground(MainActivity.java:40)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
最佳答案
您在 list 中缺少 Internet 权限。
<uses-permission android:name="android.permission.INTERNET"/>
关于Android 到达 getInputStream 时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24570679/
我正在尝试制作一个程序,显示飞机到达和起飞的时间表,然后要求用户在 C 中输入时间。然后程序将找到最接近输入时间的到达时间用户。问题是它没有按预期工作,并且给我一个错误的到达时间,甚至不接近输入的时间
我有一个不断填充新信息行的 Excel 表,其中一列与联系客户的日期(有时为空 - 无需输入日期)相关,如果在 10 内没有收到回复从那以后的几天,我们必须发送提醒,如果过了 17 天,我们必须取消订
实际到达很简单,标签进入接收器天线范围,但是偏离是造成问题的原因。 首先,我们了解一些有关设置的信息。 标签: 它们以433Mhz的速度工作,每1.5秒钟发送一次“心跳”,移动时进入传输突发模式,这种
我构建了这段代码来从 URL 获取 XML我使用了 AsyncTask,当到达 getInputStream() 点时,半身应用程序仍然崩溃 重点是我想从 url 获取 XML 作为字符串。 我尝试不
所以我有一个 TDBGrid,我的目的是搜索 DBGrid 的 Fieldname 并将其与我的编辑的 Text 属性进行比较,如果它们相等,则 我想将找到匹配项的整列写入列表框。 通过带有 fiel
我会写得非常简单,因为实际的修复并不比我不理解的实际设计重要。似乎一旦我的 @RequestBody 命中 @Controller,有关 subtype 的信息就会丢失。 假设我们有: class A
所以我正在做这个简单的动态编程问题,关于达到 n一次只能走 1 或 2 步。我知道答案基本上是一个斐波那契序列,答案是:达到n-2的步骤数+ 到达 n-1 的步数. T(n) = T(n-1) +
(function start (){ $('.bar').each(function(i){ var $bar = $(this); $(this).append('')
我有一个程序,我在启动它之前要求用户输入。 public static void main(String args[]) { String database = JOptionPane.sho
就是这样,我必须在提交按钮上有一张图片,但它根本没有出现。 我希望它看起来像这样: 现在看到我的是这样的,我不明白为什么它没有出现在页面上。 HTML CSS #sognu { bac
click here 点击后重定向至 xyz.com/#contact, 现在我想获得div #abc的顶部位置 //set the value as a variable, and remove t
here is a fiddle to know where I am starting from 我要解决的问题涉及对单个 html 文件的内容进行“分页”,以一种将它们一次锁定在一个部分中的方式。
是否可以在传递页面部分时运行 javascript 函数?我想要实现的是类似于 Twitter Bootstrap 的 scrollspy。 最佳答案 您可以使用 waypoints 插件: http
我有一个可以动态调整其大小的 iframe。我通过父页面上的发布消息和监听器解决了这个问题,因此每次 iframe 的内容发生变化时,iframe 的大小也会发生变化,并且永远不会有滚动条。 在 if
我试图让我的导航栏在到达我在网站下方设置的 anchor 时变得透明。 这是我的HTML Home About Logo W
我写了一个简单的程序来管理姓名列表(下面是程序的一部分)。我希望函数“choice()”结束并返回到 main()——从而结束程序——当用户对变量“option”的输入为 4 时。然而,choice(
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
代码片段在 while 循环后有一个 EOF,之后必须再次重新打开文件 - fopen 被重用。我的问题是是否有办法避免这种笨拙的 fopen 双重使用或以某种方式不使用 EOF? if (!(f=f
从这个页面: http://www.beta.inegi.org.mx/app/buscador/default.html?q=e15a61a 我正在尝试检索此网址: http://www.beta.
我使用维基百科的 API 来获取有关页面的信息。API 给我这样的 JSON: "query":{ "pages":{ "188791":{ "pageid":18879
我是一名优秀的程序员,十分优秀!