如何从一个实时网站的Android应用页面获取rss?

时间:2011-07-17 01:19:41

标签: android android-layout android-webview

我有一个ASP.NET网站,我想用1页开发简单的android应用程序,我希望从我的网站的RSS FEED获取实时数据。

我的网站RSS Feed的链接如下:http://www.mydomain.com/latestnewsrss.aspx?languageid=7

在Android应用程序中,我只想在列表中显示来自网站RSS FEED的所有新闻。

我正在关注本教程,但它没有运行(我不知道为什么):http://nscraps.com/Java/523-rss-feed-reader-example-java.htm

当我尝试在手机上运行我的代码时,我收到错误说“强制停止/关闭应用”

------------ log cat -------------

07-18 19:24:27.657: ERROR/Zygote(33): setreuid() failed. errno: 2
07-18 19:24:27.657: ERROR/Zygote(33): setreuid() failed. errno: 17
07-18 19:24:27.657: ERROR/BatteryService(55): usbOnlinePath not found
07-18 19:24:27.657: ERROR/BatteryService(55): batteryVoltagePath not found
07-18 19:24:27.657: ERROR/BatteryService(55): batteryTemperaturePath not found
07-18 19:24:27.657: ERROR/SurfaceFlinger(55): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
07-18 19:24:46.946: ERROR/EventHub(55): could not get driver version for /dev/input/mouse0, Not a typewriter
07-18 19:24:46.946: ERROR/EventHub(55): could not get driver version for /dev/input/mice, Not a typewriter
07-18 19:24:47.268: ERROR/System(55): Failure starting core service
07-18 19:24:47.268: ERROR/System(55): java.lang.SecurityException
07-18 19:24:47.268: ERROR/System(55):     at android.os.BinderProxy.transact(Native Method)
07-18 19:24:47.268: ERROR/System(55):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
07-18 19:24:47.268: ERROR/System(55):     at android.os.ServiceManager.addService(ServiceManager.java:72)
07-18 19:24:47.268: ERROR/System(55):     at com.android.server.ServerThread.run(SystemServer.java:184)
07-18 19:24:49.516: ERROR/SoundPool(55): error loading /system/media/audio/ui/Effect_Tick.ogg
07-18 19:24:49.546: ERROR/SoundPool(55): error loading /system/media/audio/ui/KeypressStandard.ogg
07-18 19:24:49.556: ERROR/SoundPool(55): error loading /system/media/audio/ui/KeypressSpacebar.ogg
07-18 19:24:49.566: ERROR/SoundPool(55): error loading /system/media/audio/ui/KeypressDelete.ogg
07-18 19:24:49.566: ERROR/SoundPool(55): error loading /system/media/audio/ui/KeypressReturn.ogg
07-18 19:24:52.717: ERROR/ThrottleService(55): Could not open GPS configuration file /etc/gps.conf
07-18 19:24:54.207: ERROR/logwrapper(143): executing /system/bin/tc failed: No such file or directory
07-18 19:24:54.257: ERROR/logwrapper(145): executing /system/bin/tc failed: No such file or directory
07-18 19:24:54.378: ERROR/logwrapper(146): executing /system/bin/tc failed: No such file or directory
07-18 19:25:15.453: ERROR/HierarchicalStateMachine(55): TetherMaster - unhandledMessage: msg.what=3
07-18 19:25:36.650: ERROR/ActivityManager(55): ANR in com.android.quicksearchbox
07-18 19:25:36.650: ERROR/ActivityManager(55): Reason: Broadcast of Intent { act=android.appwidget.action.APPWIDGET_ENABLED cmp=com.android.quicksearchbox/.SearchWidgetProvider }
07-18 19:25:36.650: ERROR/ActivityManager(55): Load: 4.92 / 1.38 / 0.47
07-18 19:25:36.650: ERROR/ActivityManager(55): CPU usage from 16126ms to 203ms ago:
07-18 19:25:36.650: ERROR/ActivityManager(55):   ndroid.launcher: 38% = 23% user + 14% kernel / faults: 5232 minor 63 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   system_server: 23% = 10% user + 13% kernel / faults: 2891 minor 75 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   m.android.email: 17% = 8% user + 9% kernel / faults: 4012 minor 14 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   d.process.media: 17% = 9% user + 7% kernel / faults: 4273 minor 7 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   com.android.mms: 15% = 7% user + 7% kernel / faults: 3952 minor 9 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   m.android.phone: 3% = 2% user + 1% kernel / faults: 857 minor 7 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   adbd: 3% = 0% user + 3% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):   d.process.acore: 3% = 2% user + 1% kernel / faults: 1710 minor 48 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   id.defcontainer: 1% = 0% user + 0% kernel / faults: 563 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   kswapd0: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):   zygote: 0% = 0% user + 0% kernel / faults: 159 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   roid.alarmclock: 0% = 0% user + 0% kernel / faults: 175 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   ronsoft.openwnn: 0% = 0% user + 0% kernel / faults: 174 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   mmcqd: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):   mediaserver: 0% = 0% user + 0% kernel / faults: 37 minor 2 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   init: 0% = 0% user + 0% kernel / faults: 1 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   pdflush: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):   rild: 0% = 0% user + 0% kernel / faults: 55 minor 2 major
07-18 19:25:36.650: ERROR/ActivityManager(55):   qemud: 0% = 0% user + 0% kernel / faults: 13 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   logcat: 0% = 0% user + 0% kernel / faults: 53 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):   ndroid.settings: 0% = 0% user + 0% kernel / faults: 113 minor
07-18 19:25:36.650: ERROR/ActivityManager(55):  +android.protips: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):  +.quicksearchbox: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):  +loop0: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):  +kdmflush: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):  +kcryptd_io: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):  +kcryptd: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55):  +newfs_msdos: 0% = 0% user + 0% kernel
07-18 19:25:36.650: ERROR/ActivityManager(55): TOTAL: 100% = 50% user + 48% kernel + 0% iowait + 0% irq + 0% softirq
07-18 19:25:55.430: ERROR/AndroidRuntime(305): FATAL EXCEPTION: main
07-18 19:25:55.430: ERROR/AndroidRuntime(305): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.RssFeed/com.RssFeed.RssFeed}: java.lang.IllegalAccessException: access to constructor not allowed
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.os.Looper.loop(Looper.java:123)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at java.lang.reflect.Method.invokeNative(Native Method)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at java.lang.reflect.Method.invoke(Method.java:521)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at dalvik.system.NativeStart.main(Native Method)
07-18 19:25:55.430: ERROR/AndroidRuntime(305): Caused by: java.lang.IllegalAccessException: access to constructor not allowed
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at java.lang.Class.newInstanceImpl(Native Method)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at java.lang.Class.newInstance(Class.java:1429)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
07-18 19:25:55.430: ERROR/AndroidRuntime(305):     ... 11 more

需要帮助

1 个答案:

答案 0 :(得分:2)

我看到引发了IllegalAccessException: access to constructor not allowed异常。您是否为自己的活动提供了自己的构造函数?例如,你有这样的事情:

public class YourActivity extends Activity {


    YourActivity() {

    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
 }

}

如果是这样,请记住,这不是活动的方式。您不应该为活动提供构造函数。相反,请在onCreate()方法中执行所有初始化操作。

另一个问题可能是您要实例化YourActivity activity = new YourActivity();之类的活动。这也是错误的。

请查看here以更好地了解活动生命周期。