It is working now. This code fix made it work. It is not possible to
get the resources directly in the
wallpaper service class, because that results in a nullpoint
exception. The resources have to be fetched in the renderer class, to
avoid the nullpoint exception.

in wallpaper service class:
-------------------
renderer = new GlRenderer(this);

in renderer class:
----------------
private Context context;

public GlRenderer(Context context) {
this.context = context;
((GL11) (gl)).glEnable(GL10.GL_BLEND);
bitmap1 = BitmapFactory.decodeResource(context.getResources(),
R.drawable.l11);

On Apr 4, 3:26 pm, MobileVisuals <[email protected]> wrote:
> I have investigated this now and the same nullpoint exception happens
> everytime I call any of the ContextWrapper methods. This is very
> strange because GLWallpaperService extends from ContextWrapper, so
> there is an instance of ContextWrapper. I checked this with
>
> Log.i("this", ""+this );
>
> which resulted in
>
> 04-04 13:20:28.533: INFO/this(238):
> net.markguerra.android.glwallpaperexample.MyWallpaperService@43d0f530
>
> I then get nullpoint exception on even the simplest methods in
> ContextWrapper, like isRestricted:
>
> 04-04 13:20:28.564: ERROR/AndroidRuntime(238): Caused by:
> java.lang.NullPointerException
> 04-04 13:20:28.564: ERROR/AndroidRuntime(238):     at
> android.content.ContextWrapper.isRestricted(ContextWrapper.java:455)
>
> On Apr 3, 6:55 pm, MobileVisuals <[email protected]> wrote:
>
> > Here is the out put from logcat. The error happens when I call
> > resources=this.getResources();
>
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290): FATAL EXCEPTION: main
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):
> > java.lang.RuntimeException: Unable to instantiate service
> > net.markguerra.android.glwallpaperexample.MyWallpaperService:
> > java.lang.NullPointerException
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.app.ActivityThread.handleCreateService(ActivityThread.java:
> > 2943)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.app.ActivityThread.access$3300(ActivityThread.java:125)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:2087)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.os.Handler.dispatchMessage(Handler.java:99)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.os.Looper.loop(Looper.java:123)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.app.ActivityThread.main(ActivityThread.java:4627)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.app.ActivityThread.main(ActivityThread.java:4627)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > java.lang.reflect.Method.invoke(Method.java:521)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > com.android.internal.os.ZygoteInit
> > $MethodAndArgsCaller.run(ZygoteInit.java:868)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > dalvik.system.NativeStart.main(Native Method)
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290): Caused by:
> > java.lang.NullPointerException
> > 04-03 16:48:33.422: ERROR/AndroidRuntime(290):     at
> > android.content.ContextWrapper.getResources(ContextWrapper.java:80)
> > 04-03 16:53:38.932: ERROR/AndroidRuntime(421):     at
> > net.markguerra.android.glwallpaperexample.MyWallpaperService.<init>(MyWallpaperService.java:
> > 26)
> > 04-03 16:53:38.932: ERROR/AndroidRuntime(421):     at
> > java.lang.Class.newInstanceImpl(Native Method)
> > 04-03 16:53:38.932: ERROR/AndroidRuntime(421):     at
> > java.lang.Class.newInstance(Class.java:1429)
> > 04-03 16:53:38.932: ERROR/AndroidRuntime(421):     at
> > android.app.ActivityThread.handleCreateService(ActivityThread.java:
> > 2940)
>
> > On Apr 2, 5:14 pm, Marcin Orlowski <[email protected]> wrote:
>
> > > On 2 April 2011 16:12, MobileVisuals <[email protected]> wrote:
>
> > > My problem  is that I can’t load my texture resources. The app crashes
>
> > > And the log quote is...?
>
> > > Regards,
> > > Marcin Orlowski
>
> > > *Tray Agenda <http://bit.ly/trayagenda>* - keep you daily schedule 
> > > handy...
> > > WebnetMobile on *Facebook <http://webnetmobile.com/fb/>* and
> > > *Twitter<http://webnetmobile.com/twitter/>
> > > *

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to