Error, when changing the screen orientation

schimanski

Well-Known Member
Licensed User
Longtime User
I can't find the reason for the following errormessage:

PHP:
Sorry!

The application Mapviewer(process Mapviewer5.ba) has stopped unexpectedly. Please try again.

It always happens after changing the device orientation. Some devices like the galaxy tab can change the orientation once without error. Second time, there is an error. Other devices can start the app in both modes, but it is not possible to change the orientation.


The problem have to be in the sub activity_create, because the logcat only shows this:

B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (mapviewer) Create, isFirst = true **
** Activity (mapviewer) Resume **
  
  'here, the app stops working and will be closed'

** Activity (main) Pause, UserClosed = false **
** Activity (mapviewer) Create, isFirst = false **
** Activity (mapviewer) Resume **

   'here, the app stops working and will be closed'

I don't use a service, so I can't understand, why there is no needed errormessage.

The link to the source-code is (Mapviewer5.zip):
http://www.b4x.com/forum/basic4android-share-your-creations/7323-openstreetmap-tilemapviewer-4.html#post45387

It is also possible, that I post the activity_create again in this thread..


Thanks for help...
 

klaus

Expert
Licensed User
Longtime User
I had the same error message with your program in the emulator, the problem was the size of the map bitmaps.
Reducing the number of tiles solved the problem.
Depending on the number of tiles the message appeared directly when running the program or only after some moves of the map or almost never.

Best regards.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Look in the IDE Logs tab and connect to the device and untick Filter. After it fails there is a stack trace in there somewhere near the end that will tell you the line of code where it fails.

I've run your code and I don't even need to rotate my phone for it to fail after a few seconds. The log shows a

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

The stack trace shows that this is happening in the DrawMap Sub called indirectly from your Timer2_Tick Sub

B4X:
   at Mapviewer1.ba.main._drawmap(main.java:499)
   at Mapviewer1.ba.main._initmap(main.java:736)
   at Mapviewer1.ba.main._ziele_einzeichnen(main.java:1099)
   at Mapviewer1.ba.main._timer2_tick(main.java:1058)

The actual line appears to be

CanvasTile.Initialize(Activity)
 
Upvote 0
Top