when changing geo fix by telnet, android 1.5 not detect it

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

when changing geo fix by telnet, android 1.5 not detect it

Postby zehunter » Fri Mar 12, 2010 6:25 pm

hi,

here is part of my code :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class geoSwitcher extends MapActivity implements LocationListener {
  3.  
  4.     /** Called when the activity is first created. */
  5.  
  6.    
  7.  
  8.    // ===========================================================
  9.  
  10.    // Fields
  11.  
  12.    // ===========================================================
  13.  
  14.  
  15.  
  16.    private MapView myMapView;
  17.  
  18.    private MapController mc;
  19.  
  20.    private LocationManager locationManager;
  21.  
  22.    private LocationListener locationListener;
  23.  
  24.  
  25.  
  26.    List<Overlay> mapOverlays;
  27.  
  28.    Drawable drawable;
  29.  
  30.    geoSwitcherItemizedOverlay itemizedOverlay;
  31.  
  32.    
  33.  
  34.    boolean clickable = true;
  35.  
  36.    boolean enabled = true;
  37.  
  38.    boolean satOn = false;
  39.  
  40.    boolean zoomOn = true;
  41.  
  42.    
  43.  
  44.    boolean moving = false;
  45.  
  46.    
  47.  
  48.    long startTime;
  49.  
  50.    long endTime;
  51.  
  52.    
  53.  
  54.    public boolean debugState = false;
  55.  
  56.    
  57.  
  58.    public GeoPoint p;
  59.  
  60.    public GeoPoint pMe;
  61.  
  62.    public GeoPoint pUp;
  63.  
  64.    public GeoPoint pDown;
  65.  
  66.    
  67.  
  68.    public double myLat = 40.689213;
  69.  
  70.    public double myLong = -74.044558;
  71.  
  72.    private TextView input;
  73.  
  74.  
  75.  
  76.  
  77.  
  78.     @Override
  79.  
  80.     public void onCreate(Bundle savedInstanceState) {
  81.  
  82.  
  83.  
  84.        super.onCreate(savedInstanceState);
  85.  
  86.        setContentView(R.layout.main);
  87.  
  88.  
  89.  
  90.        locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  91.  
  92.        
  93.  
  94.  
  95.  
  96.        String provider = LocationManager.GPS_PROVIDER;
  97.  
  98.        
  99.  
  100.        
  101.  
  102.        LinearLayout layout = (LinearLayout) findViewById(R.id.map_view);
  103.  
  104.        myMapView = new MapView(this,"xxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  105.  
  106.  
  107.  
  108.        // Lets start at the Statue of Liberty
  109.  
  110.        // I grabbed the data from Google-Maps
  111.  
  112.        p = new GeoPoint((int) (myLat * 1000000),
  113.  
  114.                               (int) (myLong * 1000000));
  115.  
  116.  
  117.  
  118.        // Get the controller, that is used for translation and zooming
  119.  
  120.  
  121.  
  122.       LayoutParams layoutParams = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, p, 0);
  123.  
  124.       myMapView.setLayoutParams(layoutParams);
  125.  
  126.       myMapView.setClickable(clickable);
  127.  
  128.       myMapView.setEnabled(enabled);
  129.  
  130.       // Make myMapView the exilicit view of this app
  131.  
  132.       // Enable Sattelite-Mode, so we will se the
  133.  
  134.       // Statue of liberty instantly on the screen
  135.  
  136.       myMapView.setSatellite(satOn);
  137.  
  138.       myMapView.setBuiltInZoomControls(zoomOn);
  139.  
  140.  
  141.  
  142.       layout.addView(myMapView);
  143.  
  144.      
  145.  
  146.      
  147.  
  148.       MapController mc = myMapView.getController();
  149.  
  150.       // Translate to the Statue of Liberty
  151.  
  152.       mc.animateTo(p);
  153.  
  154.       mc.setZoom(17);  
  155.  
  156.      
  157.  
  158.      
  159.  
  160.      
  161.  
  162.       input = (TextView) findViewById(R.id.lat);
  163.  
  164.       input.setText(String.valueOf(myLat));
  165.  
  166.       input = (TextView) findViewById(R.id.lng);
  167.  
  168.       input.setText(String.valueOf(myLong));
  169.  
  170.      
  171.  
  172.     }
  173.  
  174.    
  175.  
  176.     @Override
  177.  
  178.     public void onResume() {
  179.  
  180.        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30000, 0, this);
  181.  
  182.        Log.v("location ","resume");
  183.  
  184.         super.onResume();
  185.  
  186.     }
  187.  
  188.    
  189.  
  190.     @Override
  191.  
  192.     public void onPause() {
  193.  
  194.        locationManager.removeUpdates(this);
  195.  
  196.        Log.v("location ","pause");
  197.  
  198.         super.onPause();
  199.  
  200.     }
  201.  
  202.  
  203.  
  204.    
  205.  
  206.     public boolean onCreateOptionsMenu(Menu menu) {
  207.  
  208.        MenuInflater inflater = getMenuInflater();
  209.  
  210.        inflater.inflate(R.menu.options_menu, menu);
  211.  
  212.        return true;
  213.  
  214.    }
  215.  
  216.    
  217.  
  218.  
  219.  
  220.  
  221.  
  222.    @Override
  223.  
  224.    protected boolean isRouteDisplayed() {
  225.  
  226.       // TODO Auto-generated method stub
  227.  
  228.       return false;
  229.  
  230.    }
  231.  
  232.  
  233.  
  234.    @Override
  235.  
  236.    public void onLocationChanged(Location loc) {
  237.  
  238.       if (loc != null) {
  239.  
  240.          myLat = loc.getLatitude();
  241.  
  242.          myLong = loc.getLongitude();
  243.  
  244.          Log.v("location ","changed to Lat: " + loc.getLatitude() +
  245.  
  246.                " Lng: " + loc.getLongitude());
  247.  
  248.          Toast.makeText(geoSwitcher.this,
  249.  
  250.                "Location changed : Lat: " + loc.getLatitude() +
  251.  
  252.                " Lng: " + loc.getLongitude(),
  253.  
  254.                Toast.LENGTH_SHORT).show();
  255.  
  256.          
  257.  
  258.          TextView input = (TextView) findViewById(R.id.lat);
  259.  
  260.          input.setText(String.valueOf(myLat));
  261.  
  262.          input = (TextView) findViewById(R.id.lng);
  263.  
  264.          input.setText(String.valueOf(myLong));
  265.  
  266.       }
  267.  
  268.       else
  269.  
  270.       {
  271.  
  272.          Log.v("location ","not changed");
  273.  
  274.       }
  275.  
  276.    }
  277.  
  278.  
  279.  
  280.    @Override
  281.  
  282.    public void onProviderDisabled(String provider) {
  283.  
  284.       // TODO Auto-generated method stub
  285.  
  286.       Log.v("location ","provider off: "+provider.toString());
  287.  
  288.    }
  289.  
  290.  
  291.  
  292.    @Override
  293.  
  294.    public void onProviderEnabled(String provider) {
  295.  
  296.       Log.v("location ","provider on: "+provider.toString());
  297.  
  298.       // TODO Auto-generated method stub
  299.  
  300.    }
  301.  
  302.  
  303.  
  304.    @Override
  305.  
  306.    public void onStatusChanged(String provider, int status,
  307.  
  308.          Bundle extras) {
  309.  
  310.       // TODO Auto-generated method stub
  311.  
  312.       Log.v("location ","status changed "+provider.toString()+" status "+status);
  313.  
  314.    }
  315.  
  316.  
  317.  
  318. }
  319.  
  320.  
  321.  
  322.  
Parsed in 0.049 seconds, using GeSHi 1.0.8.4


when i use telnet to send geo fix position i can see firt one... but after that, all other geo fix i send (new position) is not detected ...

i'm using emulator with android 1.5

any idea how to solve this?

regards,
zehunter
Developer
Developer
 
Posts: 27
Joined: Sun Jan 10, 2010 10:45 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 5 guests