0

Google Play サービスと Google マップを使用するアプリがあります。

Eclipseからアップロードすると、マップが機能し、lastKnownLocationが正しくなります。

しかし、署名済み apk をエクスポートすると、マップが機能しません。

なぜそれができるのですか?

ここに私のコードがあります:

public class NavigationActivity extends FragmentActivity implements LocationSource, LocationListener, OnMyLocationChangeListener {

private OnLocationChangedListener mListener;
private LocationManager lManager;
private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentView(R.layout.activity_navigation);

    lManager = (LocationManager)getSystemService(LOCATION_SERVICE);
    lManager.requestLocationUpdates(lManager.getBestProvider(new Criteria(), true), 1, 1000, this);

    setUpMapIfNeeded();
}

private void setUpMapIfNeeded(){
    if (mMap == null) {
        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        mMap.setMyLocationEnabled(true);
        mMap.getUiSettings().setMyLocationButtonEnabled(false);
        mMap.setOnMyLocationChangeListener(this);

        CameraPosition camPos = new CameraPosition(new LatLng(50.088785,14.418675), 15, 60, 0);
        mMap.moveCamera(CameraUpdateFactory.newCameraPosition(camPos));
    }
}

public void activate(OnLocationChangedListener listener){mListener = listener;}

public void deactivate(){mListener = null;}

public void onLocationChanged(Location location){
    if(mListener != null){
        mListener.onLocationChanged(location);
    }
}
public void onMyLocationChange(Location location){
    if(mListener != null){
        mListener.onLocationChanged(location);
    }
}
@Override
protected void onResume(){
    super.onResume();
    setUpMapIfNeeded();
    if(lManager != null){
        lManager.requestLocationUpdates(lManager.getBestProvider(new Criteria(), true), 1, 1000, this);
    }
}
@Override
protected void onPause(){
    if(lManager != null){
        lManager.removeUpdates(this);
    }
    super.onPause();
}
@Override
public void onProviderDisabled(String provider){}
@Override
public void onProviderEnabled(String provider){}
@Override
public void onStatusChanged(String provider, int status, Bundle extras){}
@Override
public boolean onCreateOptionsMenu(Menu menu){
    getMenuInflater().inflate(R.menu.navigation, menu);
    return true;
}

public void onStop(){
    super.onStop();
    EasyTracker.getInstance(this).activityStop(this);
}
}
4

2 に答える 2