Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Uudised

Viimane: Tue, 17 May 2011 13:21:59
Teema: Nutimap Eesti kaardi asemele
Veel uudiseid »

andriod rotation

14 replies [Last post]
kenjinboy
User offline. Last seen 1 year 3 weeks ago. Offline
Joined: 02/04/2010

I put the simple app on my HTC hero
everything is good,except I rotate the phone,

the Program stoped unexpectedly

jaak
User offline. Last seen 12 hours 26 min ago. Offline
Joined: 06/19/2008

If you connect phone to to USB in debug mode, then DDMS Logcat should show all the logs. This should give more info about it. In principle rotatin should not be issue and map should be resized correctly.

/JaakL

krupenich
User offline. Last seen 1 year 3 weeks ago. Offline
Joined: 12/24/2010

I have the same problem. After couple of rotations applications falls with following error:

java.lang.OutOfMemoryError: bitmap size exceeds VM budget
ERROR/AndroidRuntime(730): at android.graphics.Bitmap.nativeCreate(Native Method)
ERROR/AndroidRuntime(730): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
ERROR/AndroidRuntime(730): at javax.microedition.lcdui.Image.createImage(Unknown Source)
ERROR/AndroidRuntime(730): at com.nutiteq.utils.Utils.resizeImageAndCopyPrevious(Unknown Source)
ERROR/AndroidRuntime(730): at com.nutiteq.BasicMapComponent.resize(Unknown Source)
ERROR/AndroidRuntime(730): at com.nutiteq.android.MapView.onDraw(Unknown Source)
ERROR/AndroidRuntime(730): at android.view.View.draw(View.java:6740)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
ERROR/AndroidRuntime(730): at android.view.View.draw(View.java:6743)
ERROR/AndroidRuntime(730): at android.widget.FrameLayout.draw(FrameLayout.java:352)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
ERROR/AndroidRuntime(730): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
ERROR/AndroidRuntime(730): at android.view.View.draw(View.java:6743)
ERROR/AndroidRuntime(730): at android.widget.FrameLayout.draw(FrameLayout.java:352)
ERROR/AndroidRuntime(730): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
ERROR/AndroidRuntime(730): at android.view.ViewRoot.draw(ViewRoot.java:1407)
ERROR/AndroidRuntime(730): at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
ERROR/AndroidRuntime(730): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
ERROR/AndroidRuntime(730): at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(730): at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(730): at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(730): at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(730): at java.lang.reflect.Method.invoke(Method.java:521)
01-10 11:34:23.923: ERROR/AndroidRuntime(730): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-10 11:34:23.923: ERROR/AndroidRuntime(730): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(730): at dalvik.system.NativeStart.main(Native Method)

I tested it on emulator and on Nexus One and the behavior of the app is the same. I'm using 1.1.0 version of lib. So, please help me to find the way to release memory when screen was rotated. The app is created by your guide for simple Android app.

jbaubort
User offline. Last seen 40 weeks 1 day ago. Offline
Joined: 07/09/2010

There are a lot of out of memory issues in the framework with Android VM.

You can take a look at my patches to the source, which fixes out of memory errors:

https://github.com/camptocamp/android-gis/blob/master/patches/MemoryCache-LinkedList.patch

https://github.com/camptocamp/android-gis/blob/master/patches/outofmemory.patch

https://github.com/camptocamp/android-gis/blob/master/patches/screencache.patch

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi,
Is there already a solution for this problem cause i got the same OutOfMemory Error if i rotate a couple times the phone.
The links from jbaubort does not exist any more...please help..!

-Thx-

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi,
I find the patch-files at "http://www.nutiteq.com/sdk-memory-bug" but I got a problem while patching.
I use eclipse, I have try the following..:
-->right click on android_maps_lib (refernced library)
--> Team --> Apply Patch --> selected the patch file, but eclipse does not found the file, which should be patched.

What I'm doing wrong..?

jaak
User offline. Last seen 12 hours 26 min ago. Offline
Joined: 06/19/2008

These are patches for SDK source, maybe you do not have it. I suggest to take latest library Beta from nutiteq.com/beta/lib - it should have this memory issue fixed.

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi jaak and thank you for ur reply..!

I've tested the rotation problem with the "android_maps_lib-1.1.1a"-library but the problem still excists..!

Do you have any idea..?

jaak
User offline. Last seen 12 hours 26 min ago. Offline
Joined: 06/19/2008

can you try https://bitbucket.org/nutiteq/android-map-samples application and tell whether same issue is there also? If so, then what is your device?

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi,
I've tried the samples and everything works fine with the rotation.
But I have noticed, that the samples are for API-Level 11 (Honeycomb Plattform 3.0).
My project also wokrs fine on that Level (11), but I've got the rotation-crash on API-Level 7 (thats the 2.1 Version).
I've tested this on a Emulator and on device (Sony Ericcson Xperia), both with the 2.1-update1 Version.

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi,
I've tried the samples and everything works fine with the rotation.
But I have noticed, that the samples are for API-Level 11 (Honeycomb Plattform 3.0).
My project also wokrs fine on that Level (11), but I've got the rotation-crash on API-Level 7 (thats the 2.1 Version).
I've tested this on a Emulator and on device (Sony Ericcson Xperia), both with the 2.1-update1 Version.

jaak
User offline. Last seen 12 hours 26 min ago. Offline
Joined: 06/19/2008

The android_samples app actually works down to 1.6. Can you give specific steps how we could replicate the issue with the sample app. So far we've been unable to replicate it.

The relevant difference can be that Sample app keeps MapComponent in Application (not in Activity), to be sure that it is singelton. I would suggest to check that your application does same. If you create MapComponent in Activity then it might be re-created in onCreate during rotation, and this is no good.

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi jaak,
Sorry but i was too busy last months to test this.

You are right, I re-created the map in the onCreate-Method,
so this could be the problem.

I tried to use the "AndroidMapApplication"-class from the
samples to see if this fix the problem, but I got an exception.

Here my test-Code..:

------------------------------------------------------------------
private MapView mapView;
private BasicMapComponent mapComponent;
private AndroidMapApplication app;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// HERE I got a java.lang.ClassCastException
this.app = (AndroidMapApplication) this.getApplication();

if(app.getTheMap() == null)
{
mapComponent = new BasicMapComponent...
app.setTheMap(mapComponent);
.
.
.

}
else
{
// restore existing map from application
mapComponent = app.getTheMap();
}
}
--------------------------------------------------------------------

I have copied the "AndroidMapApplication.java"-class in my package.

What I did wrong or did I forgot something..?

jaak
User offline. Last seen 12 hours 26 min ago. Offline
Joined: 06/19/2008

From this info it is impossible to tell. You need to make sure that you create BasicMapComponent only once (so it is singelton) and reuse this object in activities. Application is good place for it, as Application is singelton in Android apps.

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

The problem was,that I didn't change the manifest..!
When I change the application tag to..:

application android:icon="@drawable/icon" android:label="@string/app_name" android:name=".AndroidMapApplication

everything works fine. The BasicMapComponent is created once and if I rotate the device it does not crash..!

Anyway thanks again for helping..!

Nafi