java - Null pointer exception failure. Expects bitmap if not should load default pic -


i'm trying learn android, , decided try simple game andengine. idea in main menu can take pic, load pic external, or use default. can load game fine when recieves bitmap. way i'm checking see if pic present can decide load default pic must wrong. looking guys help. in advance. here chunk of code sends intent.

         intent launchintent = new intent(gameactivity.this, game.class);      startactivity(launchintent); 

here code gets intent

public class game extends simplebasegameactivity { private static int camera_width = 800; private static int camera_height = 480; private itextureregion mbackgroundtextureregion, mtowertextureregion, mring1, mring2, mring3; private sprite mtower1, mtower2, mtower3; private stack mstack1, mstack2, mstack3;  @override public engineoptions oncreateengineoptions() {     final camera camera = new camera(0, 0, camera_width, camera_height);     return new engineoptions(true, screenorientation.landscape_fixed, new ratioresolutionpolicy(camera_width, camera_height), camera); }  @override protected void oncreateresources() {     try {         // 1 - set bitmap textures         itexture backgroundtexture = new bitmaptexture(this.gettexturemanager(), new iinputstreamopener() {             bitmap bitmap = (bitmap)getintent().getparcelableextra("bitmapimage");                 @override             public inputstream open() throws ioexception {                 if (bitmap != null) {                     bytearrayoutputstream stream = new bytearrayoutputstream();                     bitmap.compress(compressformat.png, 100, stream);                     inputstream = new bytearrayinputstream(stream.tobytearray());                     return is;                 }                 else {                     return getassets().open("gfx/tower.png");                 }             }         }); 

i'm problem here somewhere in oncreateresources. again!

also, if makes difference (i doubt it). intent launched via onclick= in manifest

logcat:

08-01 02:25:41.933: e/androidruntime(825): fatal exception: main 08-01 02:25:41.933: e/androidruntime(825): java.lang.nullpointerexception 08-01 02:25:41.933: e/androidruntime(825):  @ org.andengine.ui.activity.basegameactivity.onresumegame(basegameactivity.java:222) 08-01 02:25:41.933: e/androidruntime(825):  @ org.andengine.ui.activity.basegameactivity$4.run(basegameactivity.java:373) 08-01 02:25:41.933: e/androidruntime(825):  @ android.os.handler.handlecallback(handler.java:725) 08-01 02:25:41.933: e/androidruntime(825):  @ android.os.handler.dispatchmessage(handler.java:92) 08-01 02:25:41.933: e/androidruntime(825):  @ android.os.looper.loop(looper.java:137) 08-01 02:25:41.933: e/androidruntime(825):  @ android.app.activitythread.main(activitythread.java:5041) 08-01 02:25:41.933: e/androidruntime(825):  @ java.lang.reflect.method.invokenative(native method) 08-01 02:25:41.933: e/androidruntime(825):  @ java.lang.reflect.method.invoke(method.java:511) 08-01 02:25:41.933: e/androidruntime(825):  @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 08-01 02:25:41.933: e/androidruntime(825):  @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 08-01 02:25:41.933: e/androidruntime(825):  @ dalvik.system.nativestart.main(native method) 


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -