Hi, I want to receive Events when GPS is tuned on and off.

Here my Class:

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LocationManager locMgr =
(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
        locMgr.addGpsStatusListener(mGPSStatusListener);

    }

    public Listener mGPSStatusListener = new GpsStatus.Listener() {
        public void onGpsStatusChanged(int event) {
                switch(event) {
                        case GpsStatus.GPS_EVENT_STARTED:
                                Log.d("POWER", "GPS ON > "+event);
                                break ;
                        case GpsStatus.GPS_EVENT_STOPPED:
                                Log.d("POWER", "GPS OFF > "+event);
                                break ;
                }
        }
    };
}


Whats wrong here? I don´t receive any Events :-(
In the Manifest I´ve set <uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to