onLocationChanged for android locationListener

232 views
Skip to first unread message

Эдуард Зозуля

unread,
Oct 11, 2013, 7:04:13 AM10/11/13
to he...@googlegroups.com
Hi !

I create this cod:

=== java code ====
package org.hecl.android;

import android.app.Application;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.location.GpsStatus;
import android.location.GpsStatus.Listener;
import java.util.Iterator;
import android.location.GpsSatellite;

import android.os.Handler;

import java.util.Vector;

import org.hecl.ListThing;
import org.hecl.ObjectThing;
import org.hecl.DoubleThing;
import org.hecl.HeclException;
import org.hecl.Interp;
import org.hecl.IntThing;
import org.hecl.ListThing;
import org.hecl.LongThing;
import org.hecl.ObjectThing;
import org.hecl.Properties;
import org.hecl.StringThing;
import org.hecl.Thing;

public class LocationGet extends Application {

  public static Interp interp;
  public Thing onLocationChangedCallBack = null;

  public LocationListener createListener(LocationManager locationManager) {
   
    LocationListener locationListener = new LocationListener() {
      public void onLocationChanged(Location location) {
        if (onLocationChangedCallBack != null) {
          try {
            Vector vec = ListThing.get(onLocationChangedCallBack.deepcopy());
            vec.add(ObjectThing.create(location));
--- this crash program ---->>>>>            interp.eval(ListThing.create(vec));
          } catch (HeclException he) {
            Log.v("hecl onLocationhanged callback", he.toString());
          }
        }
      }
      public void onStatusChanged(String provider, int status, Bundle extras) {}
      public void onProviderEnabled(String provider) {}
      public void onProviderDisabled(String provider) {}
    };
    return locationListener;
  }

  public void requestLocationUpdatesGPS(LocationManager locationManager, LocationListener locationListener) {
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 5, locationListener);
  }
 
  public void requestLocationUpdatesGSM(LocationManager locationManager, LocationListener locationListener) {
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 50, locationListener);
  }
 
  public void removeUpdates(LocationManager locationManager, LocationListener locationListener) {
    locationManager.removeUpdates(locationListener);
  }

  public void appDestroy() {
    //if (backgroundThread!=null) backgroundThread.interrupt();
    System.runFinalizersOnExit(true);
    System.exit(0);
  }
}
=== end java code ==========================================


in hecl this eval:

== hecl code ==
java android.location.LocationManager lm
java android.location.LocationProvider lp
java android.location.LocationListener ll
java org.hecl.android.locationGet locationget

set locationservice [$context getsystemservice LOCATION_SERVICE]
set locationGet [locationget -new {}]

set locationListener [$locationGet createListener $locationservice]
$locationGet -field onLocationChangedCallBack myproc

proc myproc { args } {

}
=== end hecl code ===



but my program crash on this row:
interp.eval(ListThing.create(vec));

What to do?

Thanks !
Reply all
Reply to author
Forward
0 new messages