2016-01-14 62 views
0

錯誤是:爲什麼在下面的代碼中實現接口「onmapreadycallback」時出現錯誤?

「公共類MapsActivity擴展FragmentActivity實現OnMapReadyCallback」

它在紅色下劃線,說要麼我宣佈我的課「抽象」或實現一個抽象方法。

該暗示說我可以實施該方法。 這是什麼意思?

package autogenie.map; 

    import android.Manifest; 
    import android.app.Activity; 
    import android.content.pm.PackageManager; 
    import android.location.Location; 
    import android.support.v4.app.ActivityCompat; 
    import android.support.v4.app.FragmentActivity; 
    import android.os.Bundle; 

    import com.google.android.gms.common.api.GoogleApiClient; 
    import com.google.android.gms.location.LocationServices; 
    import com.google.android.gms.maps.CameraUpdateFactory; 
    import com.google.android.gms.maps.GoogleMap; 
    import com.google.android.gms.maps.OnMapReadyCallback; 
    import com.google.android.gms.maps.SupportMapFragment; 
    import com.google.android.gms.maps.model.LatLng; 
    import com.google.android.gms.maps.model.MarkerOptions; 

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback { 

private GoogleMap mMap; 
GoogleApiClient mGoogleApiClient; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_maps); 


    GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this); 
    mGoogleApiClient = builder.build(); 

    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 
     // TODO: Consider calling 
     // ActivityCompat#requestPermissions 
     // here to request the missing permissions, and then overriding 
     // public void onRequestPermissionsResult(int requestCode, String[] permissions, 
     //           int[] grantResults) 
     // to handle the case where the user grants the permission. See the documentation 
     // for ActivityCompat#requestPermissions for more details. 
     return; 
    } 
    Location mLastLocation = LocationServices.FusedLocationApi 
      .getLastLocation(mGoogleApiClient); 



    } 
+1

您需要實現接口提供的方法 – SomeJavaGuy

+0

您的代碼缺少'onMapReady()'方法的實現。 –

回答

0

MapsActivity索賠implements OnMapReadyCallback但事實並非如此。

將以下添加到您的MapsActivity

@Override 
public void onMapReady(GoogleMap googleMap) { 
    // Your code here 
} 
相關問題