public boolean onOptionsItemSelected(MenuItem item) {
System.out.println("ItemId==========================>" + item.getItemId());
if(UPDATE == item.getItemId()){
String xml = downloadHTML();
System.out.println("xml is ====================>"+xml);
}else if(ABOUT == item.getItemId()){
}
// TODO Auto-generated method stub
return super.onOptionsItemSelected(item);
}
private String downloadHTML(){
HttpDownloader httpDownloader = new HttpDownloader();
String result = httpDownloader.download("http://8.chidoon.com/MP3/Mp3List.xml");
return result;
}
我是这样写的,但是http://8.chidoon.com/MP3/Mp3List.xml这个文件的内容输出为空,这个文件我是放在iis服务器上的,这样可以吗?
日志是这样的
11-27 14:18:05.609: D/AndroidRuntime(804): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-27 14:18:05.609: D/AndroidRuntime(804): CheckJNI is ON
11-27 14:18:06.350: D/AndroidRuntime(804): Calling main entry com.android.commands.pm.Pm
11-27 14:18:06.379: D/AndroidRuntime(804): Shutting down VM
11-27 14:18:06.399: D/dalvikvm(804): GC_CONCURRENT freed 101K, 71% free 297K/1024K, external 0K/0K, paused 1ms+2ms
11-27 14:18:06.409: I/AndroidRuntime(804): NOTE: attach of thread 'Binder Thread #3' failed
11-27 14:18:06.409: D/dalvikvm(804): Debugger has detached; object registry had 1 entries
11-27 14:18:06.919: D/AndroidRuntime(814): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
11-27 14:18:06.919: D/AndroidRuntime(814): CheckJNI is ON
11-27 14:18:07.619: D/AndroidRuntime(814): Calling main entry com.android.commands.am.Am
11-27 14:18:07.669: I/ActivityManager(61): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.mp3palyer/.Mp3ListActivity } from pid 814
11-27 14:18:07.683: D/AndroidRuntime(814): Shutting down VM
11-27 14:18:07.699: D/dalvikvm(814): GC_CONCURRENT freed 102K, 69% free 319K/1024K, external 0K/0K, paused 1ms+4ms
11-27 14:18:07.699: I/AndroidRuntime(814): NOTE: attach of thread 'Binder Thread #3' failed
11-27 14:18:07.712: D/dalvikvm(814): Debugger has detached; object registry had 1 entries
11-27 14:18:32.669: V/BackupManagerService(61): Backup requested but nothing pending
谁能帮我找到问题再哪里啊
3 个解决方案
#1
你的download方法写的有问题吧,可以贴出来看下么
只要能访问到,放在哪个服务器下都没有问题的
只要能访问到,放在哪个服务器下都没有问题的
#2
xml只是一种内容组成格式,跟放在哪个服务器上下载没有任何关系。
另外,你既然用了System.out.println做调试输出,那么就应该发正确的调试信息上来。
另外,你既然用了System.out.println做调试输出,那么就应该发正确的调试信息上来。
#3
大神们,再看一下吧,这是日志;
输出的xml为空,有时候会输出8.bjsbzc.net;
输出的xml为空,有时候会输出8.bjsbzc.net;
12-06 03:17:17.460: I/System.out(327): ItemId==========================>1
12-06 03:17:17.470: W/System.err(327): java.net.UnknownHostException: 8.chidoon.com
12-06 03:17:17.470: W/System.err(327): at java.net.InetAddress.lookupHostByName(InetAddress.java:506)
12-06 03:17:17.470: W/System.err(327): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)
12-06 03:17:17.470: W/System.err(327): at java.net.InetAddress.getAllByName(InetAddress.java:256)
12-06 03:17:17.470: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:69)
12-06 03:17:17.470: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
12-06 03:17:17.480: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
12-06 03:17:17.480: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
12-06 03:17:17.489: W/System.err(327): at com.example.dowload.HttpDownloader.download(HttpDownloader.java:32)
12-06 03:17:17.489: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.downloadHTML(Mp3ListActivity.java:65)
12-06 03:17:17.489: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.onOptionsItemSelected(Mp3ListActivity.java:54)
12-06 03:17:17.503: W/System.err(327): at android.app.Activity.onMenuItemSelected(Activity.java:2205)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:748)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
12-06 03:17:17.503: W/System.err(327): at android.view.View$PerformClick.run(View.java:9080)
12-06 03:17:17.503: W/System.err(327): at android.os.Handler.handleCallback(Handler.java:587)
12-06 03:17:17.503: W/System.err(327): at android.os.Handler.dispatchMessage(Handler.java:92)
12-06 03:17:17.503: W/System.err(327): at android.os.Looper.loop(Looper.java:123)
12-06 03:17:17.510: W/System.err(327): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-06 03:17:17.510: W/System.err(327): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 03:17:17.510: W/System.err(327): at java.lang.reflect.Method.invoke(Method.java:507)
12-06 03:17:17.510: W/System.err(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-06 03:17:17.510: W/System.err(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-06 03:17:17.510: W/System.err(327): at dalvik.system.NativeStart.main(Native Method)
12-06 03:17:17.510: W/System.err(327): java.lang.NullPointerException
12-06 03:17:17.521: W/System.err(327): at com.example.dowload.HttpDownloader.download(HttpDownloader.java:40)
12-06 03:17:17.521: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.downloadHTML(Mp3ListActivity.java:65)
12-06 03:17:17.521: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.onOptionsItemSelected(Mp3ListActivity.java:54)
12-06 03:17:17.530: W/System.err(327): at android.app.Activity.onMenuItemSelected(Activity.java:2205)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:748)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
12-06 03:17:17.539: W/System.err(327): at android.view.View$PerformClick.run(View.java:9080)
12-06 03:17:17.539: W/System.err(327): at android.os.Handler.handleCallback(Handler.java:587)
12-06 03:17:17.539: W/System.err(327): at android.os.Handler.dispatchMessage(Handler.java:92)
12-06 03:17:17.539: W/System.err(327): at android.os.Looper.loop(Looper.java:123)
12-06 03:17:17.539: W/System.err(327): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-06 03:17:17.539: W/System.err(327): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 03:17:17.539: W/System.err(327): at java.lang.reflect.Method.invoke(Method.java:507)
12-06 03:17:17.549: W/System.err(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-06 03:17:17.549: W/System.err(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-06 03:17:17.549: W/System.err(327): at dalvik.system.NativeStart.main(Native Method)
12-06 03:17:17.549: I/System.out(327): xml is ====================>
12-06 03:17:17.620: W/InputManagerService(70): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40796318
#1
你的download方法写的有问题吧,可以贴出来看下么
只要能访问到,放在哪个服务器下都没有问题的
只要能访问到,放在哪个服务器下都没有问题的
#2
xml只是一种内容组成格式,跟放在哪个服务器上下载没有任何关系。
另外,你既然用了System.out.println做调试输出,那么就应该发正确的调试信息上来。
另外,你既然用了System.out.println做调试输出,那么就应该发正确的调试信息上来。
#3
大神们,再看一下吧,这是日志;
输出的xml为空,有时候会输出8.bjsbzc.net;
输出的xml为空,有时候会输出8.bjsbzc.net;
12-06 03:17:17.460: I/System.out(327): ItemId==========================>1
12-06 03:17:17.470: W/System.err(327): java.net.UnknownHostException: 8.chidoon.com
12-06 03:17:17.470: W/System.err(327): at java.net.InetAddress.lookupHostByName(InetAddress.java:506)
12-06 03:17:17.470: W/System.err(327): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294)
12-06 03:17:17.470: W/System.err(327): at java.net.InetAddress.getAllByName(InetAddress.java:256)
12-06 03:17:17.470: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:69)
12-06 03:17:17.470: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
12-06 03:17:17.480: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
12-06 03:17:17.480: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018)
12-06 03:17:17.489: W/System.err(327): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
12-06 03:17:17.489: W/System.err(327): at com.example.dowload.HttpDownloader.download(HttpDownloader.java:32)
12-06 03:17:17.489: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.downloadHTML(Mp3ListActivity.java:65)
12-06 03:17:17.489: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.onOptionsItemSelected(Mp3ListActivity.java:54)
12-06 03:17:17.503: W/System.err(327): at android.app.Activity.onMenuItemSelected(Activity.java:2205)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:748)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
12-06 03:17:17.503: W/System.err(327): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
12-06 03:17:17.503: W/System.err(327): at android.view.View$PerformClick.run(View.java:9080)
12-06 03:17:17.503: W/System.err(327): at android.os.Handler.handleCallback(Handler.java:587)
12-06 03:17:17.503: W/System.err(327): at android.os.Handler.dispatchMessage(Handler.java:92)
12-06 03:17:17.503: W/System.err(327): at android.os.Looper.loop(Looper.java:123)
12-06 03:17:17.510: W/System.err(327): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-06 03:17:17.510: W/System.err(327): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 03:17:17.510: W/System.err(327): at java.lang.reflect.Method.invoke(Method.java:507)
12-06 03:17:17.510: W/System.err(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-06 03:17:17.510: W/System.err(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-06 03:17:17.510: W/System.err(327): at dalvik.system.NativeStart.main(Native Method)
12-06 03:17:17.510: W/System.err(327): java.lang.NullPointerException
12-06 03:17:17.521: W/System.err(327): at com.example.dowload.HttpDownloader.download(HttpDownloader.java:40)
12-06 03:17:17.521: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.downloadHTML(Mp3ListActivity.java:65)
12-06 03:17:17.521: W/System.err(327): at com.example.mp3palyer.Mp3ListActivity.onOptionsItemSelected(Mp3ListActivity.java:54)
12-06 03:17:17.530: W/System.err(327): at android.app.Activity.onMenuItemSelected(Activity.java:2205)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:748)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
12-06 03:17:17.530: W/System.err(327): at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
12-06 03:17:17.539: W/System.err(327): at android.view.View$PerformClick.run(View.java:9080)
12-06 03:17:17.539: W/System.err(327): at android.os.Handler.handleCallback(Handler.java:587)
12-06 03:17:17.539: W/System.err(327): at android.os.Handler.dispatchMessage(Handler.java:92)
12-06 03:17:17.539: W/System.err(327): at android.os.Looper.loop(Looper.java:123)
12-06 03:17:17.539: W/System.err(327): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-06 03:17:17.539: W/System.err(327): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 03:17:17.539: W/System.err(327): at java.lang.reflect.Method.invoke(Method.java:507)
12-06 03:17:17.549: W/System.err(327): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-06 03:17:17.549: W/System.err(327): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-06 03:17:17.549: W/System.err(327): at dalvik.system.NativeStart.main(Native Method)
12-06 03:17:17.549: I/System.out(327): xml is ====================>
12-06 03:17:17.620: W/InputManagerService(70): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40796318