代码如下,获取位置信息时总是返回null,不知道什么原因,哪位大侠帮我看看
1 package polly.liu; 2 3 import java.util.List; 4 5 import org.apache.http.client.methods.HttpGet; 6 7 import android.app.Activity; 8 import android.app.AlertDialog; 9 import android.content.Context; 10 import android.content.Intent; 11 import android.os.Bundle; 12 import android.widget.EditText; 13 import android.location.Location; 14 import android.location.LocationManager; 15 16 public class TestPollyActivity extends Activity { 17 /** Called when the activity is first created. */ 18 @Override 19 public void onCreate(Bundle savedInstanceState) { 20 super.onCreate(savedInstanceState); 21 setContentView(R.layout.main); 22 LocationManager locMgr = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE); 23 Location loc = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER); 24 //List<String> providerList = locMgr.getAllProviders(); 25 //EditText positionText = (EditText)this.findViewById(R.id.editPosition); 26 new AlertDialog.Builder(this).setTitle(String.valueOf(loc)).setView(new EditText(this)).setPositiveButton("留名", null).setNegativeButton("取消", null).show(); 27 } 28 }