[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Well it worked if i just did it from the AppWidgetProvider.onUpdate. And this service i wrote uses the same approach as Jeff Sharkey (Android Team Developer) uses in his example Widget: http://code.google.com/p/android-sky/source/browse/trunk/Sky/src/org/jsharkey/sky/UpdateService.java So what

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
B.t.w it worked fine on the Emulator intially (no widget where loaded previously) On Jul 14, 10:44 am, Kostya Vasilyev kmans...@gmail.com wrote: Are you calling updateAppWidget from the worker thread? If so, don't. UI calls can only be made from the UI thread. Use a Handler / Runnable to

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Kostya Vasilyev
But what about the thread? 14.07.2010 14:09, TjerkW пишет: B.t.w it worked fine on the Emulator intially (no widget where loaded previously) On Jul 14, 10:44 am, Kostya Vasilyevkmans...@gmail.com wrote: Are you calling updateAppWidget from the worker thread? If so, don't. UI calls can

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Okay am i now using a IntentService without a thread But now i get an ANR on a broadcast: 07-14 13:38:49.503: WARN/ActivityManager(59): Timeout of broadcast BroadcastRecord{43f724c0 android.appwidget.action.APPWIDGET_ENABLED} - receiver=android.os.binderpr...@43deed00 07-14 13:38:49.513:

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Mark Murphy
On Wed, Jul 14, 2010 at 7:44 AM, TjerkW tje...@gmail.com wrote: 07-14 13:38:49.503: WARN/ActivityManager(59): Timeout of broadcast BroadcastRecord{43f724c0 android.appwidget.action.APPWIDGET_ENABLED} - receiver=android.os.binderpr...@43deed00 07-14 13:38:49.513: WARN/ActivityManager(59):

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Request update is a very fast method /** * Request updates for the given widgets. Will only queue them up, you are * still responsible for starting a processing thread if needed, usually by * starting the parent service. */ public static void requestUpdate(int[]

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Works on the emulator.. but on my nexus one i still get the nasty nullpointerexception deep inside the Android apis 07-14 14:33:53.105: ERROR/HyvesWidgetService(13806): Failed updating widget: 68, due to java.lang.NullPointerException 07-14 14:33:53.105: WARN/System.err(13806):

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Mark Murphy
On Wed, Jul 14, 2010 at 8:35 AM, TjerkW tje...@gmail.com wrote: Works on the emulator.. but on my nexus one i still get the nasty nullpointerexception deep inside the Android apis At this point, I am fairly lost with your code. I don't know why you need onUpdate() to fork a thread. Make sure

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Okay i have that now and i still get the nullpointerexception on an Nexus One. I still use a separate thread because the client libray i use does a asyncrhonous api call. But i syncrhonize it by an object lock. So it should work fine.. but it doesnt. On Jul 14, 2:50 pm, Mark Murphy

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Kostya Vasilyev
From what thread are you ultimately calling AppWidgetManager.updateAppWidget ? It has to be the UI thread, I think you should check to make sure. -- Kostya 14.07.2010 16:35, TjerkW пишет: Works on the emulator.. but on my nexus one i still get the nasty nullpointerexception deep inside the

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Mark Murphy
On Wed, Jul 14, 2010 at 9:01 AM, Kostya Vasilyev kmans...@gmail.com wrote: From what thread are you ultimately calling AppWidgetManager.updateAppWidget ? It has to be the UI thread, I think you should check to make sure. No, it doesn't. I have a few examples where updating the app widget

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Im calling it from the IntentService onHandleIntent method which should run in its own worker thread as the apidocs explain. It works on the emulator. However on the Nexus One i get the nullpointer exception on calling manager.updateAppWidget ... See the stacktrace in a previous post. On Jul 14,

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Kostya Vasilyev
Mark, AFAIK, all UI methods are supposed to be called from the UI thread, are widget calls an exception to this rule? -- Kostya 14.07.2010 17:12, Mark Murphy пишет: On Wed, Jul 14, 2010 at 9:01 AM, Kostya Vasilyevkmans...@gmail.com wrote: From what thread are you ultimately calling

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Mark Murphy
On Wed, Jul 14, 2010 at 9:27 AM, Kostya Vasilyev kmans...@gmail.com wrote: AFAIK, all UI methods are supposed to be called from the UI thread, are widget calls an exception to this rule? An app widget has nothing to do with the UI...from your application's standpoint. The home screen probably

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Hmm yeah,.. im trying to make a simple widget now and adding more stuff. However maybe this output from LogCat also helps: 07-14 15:57:58.845: ERROR/ActivityManager(59): ANR in com.hyves.android.application 07-14 15:57:58.845: ERROR/ActivityManager(59): Reason: Broadcast of Intent {

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Kostya Vasilyev
Right, actual views live in a separate process altogether and RemoteViews is marshalled to this process... That's understood. But an AppWidgetProvider is a broadcast receiver, and its methods are called on a certain thread within the containing process. Is it safe to call updateAppWidget and

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Mark Murphy
On Wed, Jul 14, 2010 at 10:00 AM, TjerkW tje...@gmail.com wrote: Hmm yeah,.. im trying to make a simple widget now and adding more stuff. However maybe this output from LogCat also helps: 07-14 15:57:58.845: ERROR/ActivityManager(59): ANR in com.hyves.android.application 07-14

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Mark Murphy
On Wed, Jul 14, 2010 at 10:04 AM, Kostya Vasilyev kmans...@gmail.com wrote: But an AppWidgetProvider is a broadcast receiver, and its methods are called on a certain thread within the containing process. Is it safe to call updateAppWidget and other methods (such as getAppWidgetIds) from a

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Tjerk Gmail
Aaah cool i didnt think of that problem! On Jul 14, 2010, at 4:15 PM, Mark Murphy wrote: On Wed, Jul 14, 2010 at 10:00 AM, TjerkW tje...@gmail.com wrote: Hmm yeah,.. im trying to make a simple widget now and adding more stuff. However maybe this output from LogCat also helps: 07-14

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Kostya Vasilyev
... which is in turn caused by a crash: 07-14 10:30:36.796: ERROR/AndroidRuntime(12077): FATAL EXCEPTION: Thread-16 07-14 10:30:36.796: ERROR/AndroidRuntime(12077): java.lang.NullPointerException 07-14 10:30:36.796: ERROR/AndroidRuntime(12077): at android.widget.RemoteViews

[android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread TjerkW
Thanks... it was not a threading issue... i was calling views.setImageViewBitmap(R.id.profile_image, icon); with a null icon Most stupid mistake ever. But i think it would be better if android throws a better exception with a clear message. Anyways... solved! And a lot learned today!

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Kostya Vasilyev
It does - 07-14 10:30:36.796: ERROR/AndroidRuntime(12077): java.lang.NullPointerException How more specific can you get? -- Kostya 14.07.2010 19:42, TjerkW пишет: Thanks... it was not a threading issue... i was calling views.setImageViewBitmap(R.id.profile_image, icon); with a null

Re: [android-developers] Re: AppWidgetManager updateAppWidget throws NullPointerException

2010-07-14 Thread Tjerk Wolterink
The problem was that sometimes the icon was not null and sometimes it was... so was searching for a threading issue. You could be more specific to throw a nullpointerexception straight away in the api. NullPointerException(media cannot be null). But that requires some cpu cycles... 2010/7/14