ユーザーが場所を変更するたびにユーザーに通知したいと思います。の中にトーストを挿入しましたが、 fromonLocationChanged
にレッドラインがあります。それは言うmakeText
toast.makeText
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (CurrentLocationOverlay, String, int)
それから私は
Toast.makeText(this,"Your current speed is :" +gps.getSpeed, Toast.LENGTH_SHORT).show()
にToast.makeText(getBaseContext(),"Your current speed is :" +gps.getSpeed, Toast.LENGTH_SHORT).show().
それから、getBaseContext()
メソッドを作成するように言われました。に変更しましたgetApplicationContext()
。それでも同じ答えです。クラス名に変更しても同じです
public class CurrentLocationOverlay extends MyLocationOverlay {
GPSTracker gps;
@Override
public synchronized void onLocationChanged(Location location) {
super.onLocationChanged(location);
Toast.makeText(this,"Your current speed is :" +gps.getSpeed(),
Toast.LENGTH_SHORT).show();
// only move to new position if enabled and we are in an border-area
if (mc != null && centerOnCurrentLocation && inZoomActiveArea(currentPoint)) {
mc.animateTo(getMyLocation());
}}
}