简体   繁体   中英

Android Problem on Widget ImageButton click

I'm new in Android development, and my English is awfull.

I have an application with a homescreen widget.

When I start application, in main activity, I can select options for widget (these options are saved to a DB).

Then, I add a Widget, that it have an ImageButton on it, to the homescreen. The click on ImageButton works fine.

If I kill the application activity with some Task Manager, delete the widget, and add it again. The click on ImageButton crash.

Is this normally?

Here you have the error:

java.lang.RuntimeException: Unable to start service cat.aat.quoteswidget.Widget$UpdateService@45d1b188 with Intent { cmp=cat.aat.quoteswidget/.Widget$UpdateService }: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3282)
at android.app.ActivityThread.access$3600(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2211)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:144)
at android.app.ActivityThread.main(ActivityThread.java:4937)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at cat.aat.quoteswidget.Widget$UpdateService.buildUpdate(Widget.java:130)
at cat.aat.quoteswidget.Widget$UpdateService.onStart(Widget.java:90)
at android.app.Service.onStartCommand(Service.java:420)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3267)
... 10 more

Thanks!

Widget.java文件的第130行的UpdateServicebuildUpdate()方法中,您有一个NullPointerException

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM