Bug 6032 - OnLocationChanged() event not fired
Summary: OnLocationChanged() event not fired
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.2.x
Hardware: All Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-07-07 14:39 UTC by ASHISH VAISH
Modified: 2013-12-05 18:35 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description ASHISH VAISH 2012-07-07 14:39:43 UTC
I am deploying a sample solution for GPS Location in a tablet having Android 2.2.
This sample Program is working Fine on Android Emulator and tested by telnet using geo fix command but when i deploy it on android tablet its does not work and not giving location.

sample code is here


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.Locations;
using System.Threading;

namespace MapsAndLocationDemo
{
    [Activity (Label = "LocationActivity")]          
    public class LocationActivity : Activity,ILocationListener
    {
        LocationManager _locMgr;
        TextView locationText;
         
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView (Resource.Layout.LocationView);
            locationText = FindViewById<TextView>(Resource.Id.locationTextView);
            // use location service directly       
            _locMgr = (LocationManager)GetSystemService(LocationService);


           

            Location lastKnownLocation = _locMgr.GetLastKnownLocation("gps");

            if (lastKnownLocation != null)
            {
                locationText.Text = String.Format("Started....." + "\r\n");
                locationText.Text += string.Format("Last known location, lat: {0}, long: {1}", lastKnownLocation.Latitude, lastKnownLocation.Longitude);
            }
            else
            {
               
                locationText.Text = String.Format("Started....." + "\r\n");
                locationText.Text += string.Format("Last location unknown");
            }
            _locMgr.RequestLocationUpdates("gps", 0, 0, this);

           
        }
     
        protected override void OnResume ()
        {
            base.OnResume ();

           _locMgr.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, this);

        }
        
        protected override void OnPause ()
        {
            base.OnPause ();

            _locMgr.RemoveUpdates(this);
        }


        public void OnLocationChanged(Location location)
        {
           locationText.Text = String.Format("Latitude = {0}, Longitude = {1}", location.Latitude, location.Longitude);

            
        }

        public void OnProviderDisabled(string provider)
        {
           
        }

        public void OnProviderEnabled(string provider)
        {
            
        }

        public void OnStatusChanged(string provider, Availability status, Bundle extras)
        {
          
        }

    }

    
}


and 

 <uses-permission android:name="android.permission.ACCESS_GPS" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.INTERNET" />
Comment 1 ASHISH VAISH 2012-07-09 00:46:24 UTC
Hi;

I testing on testing having SiRF3 AGPS.

It will work with device??
Comment 2 Atsushi Eno 2012-09-10 10:05:56 UTC
I created equivalent code without MfA i.e. just with Android SDK and ADT with Eclipse, and I couldn't get any results either. The cause of the problem is likely somewhere in this code itself. If you could get this Java code working with or without changes, please reopen and we'll ask more details.

package name.atsushieno.testing.dummyandroidapp;

import android.app.Activity;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.method.KeyListener;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;

public class MainActivity extends Activity implements LocationListener {
	LocationManager _locMgr;
    TextView locationText;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView (R.layout.main);
        locationText =
(TextView) findViewById (R.id.locationTextView);
        // use location service directly       
        _locMgr = (LocationManager)getSystemService(LOCATION_SERVICE);

        Location lastKnownLocation = _locMgr.getLastKnownLocation("gps");

        if (lastKnownLocation != null)
        {
            locationText.setText (String.format("Started.....\r\nLast known location, lat:%d, long: %d", lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude()));
        }
        else
        {

            locationText.setText ("Started.....\r\nLast location unknown");
        }
        _locMgr.requestLocationUpdates("gps", 0, 0, this);
    }
    
    @Override
    protected void onResume()
    {
    	super.onResume();
    	_locMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
    }
    
    @Override
    protected void onPause()
    {
        super.onPause ();

        _locMgr.removeUpdates(this);
    }
    
    public void onLocationChanged(Location location)
    {
       locationText.setText (String.format("Latitude = %d, Longitude = %d", location.getLatitude(), location.getLongitude()));
    }

    public void onProviderDisabled(String provider)
    {

    }

    public void onProviderEnabled(String provider)
    {

    }

    public void onStatusChanged(String provider, int status,
Bundle extras)
    {

    }
}
Comment 3 PJ 2013-11-19 17:05:28 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 4 PJ 2013-12-05 18:35:51 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.