Hello everybody,
Im making Java me application for Symbian S60 5th edition and I have problem with the memory. After some time of running the app I recieve the out of memory exception. So,Im getting images from GoogleMaps(by the integrated GPS in nokia 5800) and showing them.
I have this implemented like this:
- class MIDlet with metod setForm()
- class Data which has thread that collects info about the coordinates, gets image from google maps, create new form, append the image, and call the method setForm(f) from the Midlet.
Probable the Display.setCurrent(Form f)
keeps references on the forms and like this the memory gets fast full.
I tried with Canvas but it has some stupid UI(some circle and some 4 buttons) that I dont like.
Any idea how to solve the problem?
thanks in advanced,
Milan
PS: the code....
In class MIDlet
public void setInfo(Form f) { getDisplay().setCurrent(f); }
in class TouristData which collect information about location and gets map image
private attributes: private Form f=null; private ImageItem imageItem=null; private Image img = null;
method locationUpdated which is called when recieve new location:
public void locationUpdated(LocationProvider provider,final Location location)
{
if (!firstLocationUpdate)
{
firstLocationUpdate = true;
statusListener.firstLocationUpdateEvent();
}
if(touristUI != null)
{
new Thread()
{
public void run()
{
if(location != null && location.isValid())
{
//lokacija je, prikaži!
try
{
QualifiedCoordinates coord =location.getQualifiedCoordinates();
if(imageItem == null)
{
imageItem = new ImageItem(null,null,0,null);
imageItem.setAltText("ni povezave");
f.append(imageItem);
}
else
{
img = googleConnector.retrieveStaticImage2(360,470, coord.getLatitude(), coord.getLongitude(), 16, "png32"); //z markerje
imageItem.setImage(img);
}
}catch(Exception e)
{}
}
else
{
}
}
}.start();
}
}