为什么位置管理器为空

时间:2013-07-24 15:40:56

标签: android

为什么myLocationManager为null.explanation将不胜感激

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;

2 个答案:

答案 0 :(得分:2)

因为你在这里设置为null?

private LocationManager myLocationManager=null;

答案 1 :(得分:1)

没有理由在类

中将myLocationManager显式设置为null
public class GeoWebOne extends Activity {
  private static String PROVIDER=LocationManager.GPS_PROVIDER;
  private WebView browser;
  private LocationManager myLocationManager;

也会有效;并且可能稍微容易阅读。