MainActivity
public class MainActivity extends AppCompatActivity { private TextView locationTv; LocationManager lm; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); locationTv = (TextView) findViewById(R.id.tv_location); // 第一步:获得定位管理者对象 lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // 第二部:申请开启定位监听 // NETWORK_PROVIDER :粗略定位 GPS_PROVIDER :精准定位