• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

problem with Toast.maketext

Rma

Lurker
Code:
package com.androidbook.GPS_Sensor_Project;

import android.app.Activity;
import android.content.Context;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

public class GPS_Sensor_ProjectActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        LocationListener locationListener = new MyLocationListener();
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
        
        
    }
    
}
==========================================================

Code:
package com.androidbook.GPS_Sensor_Project;

import android.content.Context;
import android.content.ContextWrapper;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.widget.Toast;

public class MyLocationListener implements LocationListener {

	@Override
	public void onLocationChanged(Location loc) {
		// TODO Auto-generated method stub
        loc.getLatitude();
        loc.getLongitude();
        String text = "current location is: " + "latitude = " +loc.getLatitude() +
        		                                "longitude = " +loc.getLongitude();
        [COLOR="Red"][B]Toast.makeText(Context.LOCATION_SERVICE[/B][/COLOR], "location changed", Toast.LENGTH_SHORT).show();
	}

	@Override
	public void onProviderDisabled(String arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onProviderEnabled(String arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub

	}

}
 
Back
Top Bottom