2017-05-20 7 views
-2

Ich möchte wissen, dass Callback ist von welchem ​​Paket .... Ich verwende dies in MapActivity, um den Live-Standort zu finden.kann nicht auflösen Callback in android Studio

Rückruf subscribeCallback = new Rückruf() {

@Override 
    public void successCallback(String channel, Object message) { 
     JSONObject jsonMessage = (JSONObject) message; 
     try { 
      double mLat = jsonMessage.getDouble("lat"); 
      double mLng = jsonMessage.getDouble("lng"); 
      mLatLng = new LatLng(mLat, mLng); 
     } catch (JSONException e) { 

     } 

     runOnUiThread(new Runnable() { 
      @Override 
      public void run() { 
       updatePolyline(); 
       updateCamera(); 
       updateMarker(); 
      } 
     }); 
    } 
}; 

Antwort

0

public class MapsActivity erweitert FragmentActivity implementiert OnMapReadyCallback {

private GoogleMap mGoogleMap; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_maps); 
    // Obtain the SupportMapFragment and get notified when the map is ready to be used. 
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() 
      .findFragmentById(R.id.map); 
    mapFragment.getMapAsync(this); 
} 

@Override 
public void onMapReady(GoogleMap googleMap) { 
    mGoogleMap = googleMap; 
    initializeMap(); 
} 
private PolylineOptions mPolylineOptions; 

private void initializeMap() { 
    mPolylineOptions = new PolylineOptions(); 
    mPolylineOptions.color(Color.BLUE).width(10); 
} 

private LatLng mLatLng; 







Callback subscribeCallback = new Callback() { 

    @Override 
    public void successCallback(String channel, Object message) { 
     JSONObject jsonMessage = (JSONObject) message; 
     try { 
      double mLat = jsonMessage.getDouble("lat"); 
      double mLng = jsonMessage.getDouble("lng"); 
      mLatLng = new LatLng(mLat, mLng); 
     } catch (JSONException e) { 

     } 

     runOnUiThread(new Runnable() { 
      @Override 
      public void run() { 
       updatePolyline(); 
       updateCamera(); 
       updateMarker(); 
      } 
     }); 
    } 
}; 
private void updatePolyline() { 
    mGoogleMap.clear(); 
    mGoogleMap.addPolyline(mPolylineOptions.add(mLatLng)); 
} 
private void updateMarker() { 
    mGoogleMap.addMarker(new MarkerOptions().position(mLatLng)); 
} 
private void updateCamera() { 
    mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16)); 
} 

}

+0

Problem gleiche ist bleiben, kann nicht Rückruf lösen, das ist Warum möchte ich wissen, dass dieser Rückruf von welcher Klasse ist –

Verwandte Themen