简体   繁体   中英

Android Studio Location API implementing class signature

Guys how Do I change the class signature to implement googleapiclient? If you click on image it shows the tutorial but doesn't show clearly what to do. I don't understand when it says implement it because I don't know how? Can anyone help?

在此处输入图片说明

Here is my code:

public class MainActivity extends ActionBarActivity {
    //private LocationManager locationManager;
    private Location currentLocation;
    private TextView locationText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        locationText = (TextView) findViewById(R.id.textView1);
    }

    private void updateDisplay(){
        if (currentLocation==null){
            locationText.setText("determining your location...");
        } else {
            locationText.setText(
                    String.format("Your location:\n%2f, %.2f", currentLocation.getLatitude(),
                            currentLocation.getLongitude()));

        }
    }

    private LocationListener mListener = new LocationListener(){
        @Override
        public void onLocationChanged(Location location){
            currentLocation=location;
            updateDisplay();
        }

        @Override
        public void onProviderDisabled(String provider){
        }

        @Override
        public void onProviderEnabled(String provider){
        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras){
        }
    };

    @Override
    public void onResume(){
        super.onResume();
        //currentLocation = locationManager.getLastKnownLocation(locationManager.GPS_PROVIDER);
        updateDisplay();
        //locationManager.requestLocationUpdates(locationManager.GPS_PROVIDER, 0, 0, mListener);
    }

    @Override
    public void onPause(){
        super.onPause();
        //locationManager.removeUpdates(mListener);
    }

how Do I change the class signature to implement googleapiclient?

Add implements GoogleApiClient.ConnectionCallbacks to your class, and implement the methods that it requires .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM