我有以下课程:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
XmlManager xm = new XmlManager();
Log.i("tag",documentToString(xm.getXmlFromUrl("http://domen.com/abc/timelist.xml")));
}
//................
}
public class XmlManager {
public Document getXmlFromUrl(String url) {
GetXmlTask txt = new GetXmlTask();
txt.execute(url);
Document doc = null;
try {
doc = txt.get(5, TimeUnit.SECONDS);
Log.i("tag", "test");
}
catch (Exception e) {
e.printStackTrace();
}
return doc;
}
//................
}
public class GetXmlTask extends AsyncTask<String, Void, org.w3c.dom.Document> {
@Override
protected Document doInBackground(String... arg0) {
String url = "";
if( arg0.length > 0 ){
url = arg0[0];
}
Document doc = null;
try {
doc = stringToDom(convertStreamToString(new URL(url).openStream()));
}
catch (Exception e) {
e.printStackTrace();
}
return doc;
}
//................
}
不幸的是,我不明白错误存在于哪里。我在 LogCat 中看到(没有过滤器):
01-24 17:47:44.194:W/Zygote(37):预加载的可绘制资源因配置而异!!01-24 17:47:44.204: W/Zygote(37): 预加载的可绘制资源 #0x1080446 (res/drawable-mdpi/popup_inline_error_above_holo_light.9.png),随配置而变化!!01-24 17:47:44.284: W/Zygote(37): 预加载的可绘制资源 #0x1080447 (res/drawable-mdpi/popup_inline_error_holo_dark.9.png),随配置而异!!01-24 17:47:44.294: W/Zygote(37): 预加载的可绘制资源 #0x1080448 (res/drawable-mdpi/popup_inline_error_holo_light.9.png),随配置而异!!01-24 17:47:46.315: W/Zygote(37): 预加载的可绘制资源 #0x10802ec (res/drawable-mdpi/ic_lockscreen_outerring.png) 随配置而变化!!01-24 17:47:48.644:A/BatteryStatsImpl(93):原因:libcore.io.ErrnoException:打开失败:/mnt/sdcard/.android_secure/',跳过:权限被拒绝。01-24 17:48:44.462: I/ActivityManager(93): 启动 proc com.svox.pico 广播 com.svox.pico/.VoiceDataInstallerReceiver: pid=541 uid=10024 gids={1015} 01-24 17: 48:51.142: W/NetworkManagementSocketTagger(93): setKernelCountSet(10041, 1) 失败,错误号 -2 01-24 17:48:55.792: W/NetworkManagementSocketTagger(93): setKernelCountSet(10005, 0) 失败,错误号 -2
按应用程序名称过滤:LogCat 中有 void。
按标签“标签”过滤:
01-24 17:48:03.064: W/NetworkManagementSocketTagger(93): setKernelCountSet(10005, 1) 失败,错误号 -2 01-24 17:48:51.142: W/NetworkManagementSocketTagger(93): setKernelCountSet(10041, 1) 失败使用 errno -2 01-24 17:48:55.792: W/NetworkManagementSocketTagger(93): setKernelCountSet(10005, 0) 失败,出现 errno -2