-6

WHY myLocationManager is null.explanation will be appreciated

package com.commonsware.android.geoweb;

    import android.app.Activity;        
    import android.content.Context;             
    import android.os.Bundle;                
    import android.location.Location;        
    import android.location.LocationListener;       
    import android.location.LocationManager;         
    import android.webkit.WebView;    
    import org.json.JSONException;    
    import org.json.JSONObject;    

    public class GeoWebOne extends Activity {
      private static String PROVIDER=LocationManager.GPS_PROVIDER;
      private WebView browser;
      private LocationManager myLocationManager=null;
4

2 回答 2

2

因为你在这里设置为空?

private LocationManager myLocationManager=null;
于 2013-07-24T15:41:57.673 回答
1

没有理由myLocationManager在类中显式设置为 null

public class GeoWebOne extends Activity {
  private static String PROVIDER=LocationManager.GPS_PROVIDER;
  private WebView browser;
  private LocationManager myLocationManager;

本来也可以的;并且可能更容易阅读。

于 2013-07-24T15:48:37.337 回答