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: Thu, 15 Mar 2012 14:51:08
Teema: Vabad töökohad pakkuda
Veel uudiseid »

How to use properly onPause()/onResume()

1 reply [Last post]
leilameherzi
User offline. Last seen 48 weeks 19 hours ago. Offline
Joined: 04/19/2011

Hi all,

I'm working on a class (class A) containing a mapView and some other layers.
When calculating itinerary, I have the possibility to show the road instructions on a listView called on another class (class B).
From the listView, when pressing/selection an instruction, my app should go back to the map class (class A) to focus on that instruction coordinates.
The problem is, when coming back to the map class (class A), I got an error and my app crashes.
Here is the code of ListView (class B ) calling mapView class (class A).


final Intent i = new Intent(this, MapItineraire.class);
maListViewPerso.setOnItemClickListener(new OnItemClickListener() {
@Override
@SuppressWarnings("unchecked")
public void onItemClick(AdapterView<?> a, View v, int position,
long id) {

Bundle infoBundle = new Bundle();
infoBundle.putInt("position", position);
i.putExtras(infoBundle);
startActivity(i);

}

});

the mapView class contain MapView, some Layouts(as layers),
LocationListner...
I kept on resume empty, I got the crash

@Override
protected void onResume() {
super.onResume();
Bundle extras = getIntent().getExtras();
if (extras != null) {
position = extras.getInt("position");
}
}

PS: I can get the extra but the app crashes.

How can I reload the last State of mapView and the found itinerary when resuming ???

jaak
User offline. Last seen 4 days 19 hours ago. Offline
Joined: 06/19/2008

I would suggest to keep the MapComponent as singleton in the Application, so you do not recreate it with stop and resume of any Activity. We have recent better Android sample available in https://bitbucket.org/nutiteq/android-map-samples . It uses Application and shows many other general Maps lib features, and some specific tricks in Android: how to show route instructions, how to implement Search with Android API etc. There is also latest SDK, you need to use this to run the sample.

/JaakL