Đang chuẩn bị liên kết để tải về tài liệu:
lập trình android (phần 7)

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Tham khảo tài liệu 'lập trình android (phần 7)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 276 Chapter 11 Location location location public void onStart super.onStart this.locationManager LocationManager Instantiate LocationManager this.getSystemService Context. LOCATION_SERVICE 1 system service this.locationProvider this.locationManager.getProvider LocationManager. GPS_PROVIDER n Assign GPS LocationListeners omitted here for brevity LocationProvider GeoPoint lastKnownPoint this.getLastKnownPoint this.mapController this.mapView.getController this.mapController.setZoom 10 this.mapController.animateTo lastKnownPoint this.getBuoyData lastKnownPoint . . . onResume and onPause omitted for brevity . . . other portions of MapViewActivity are included in later listings in this chapter private GeoPoint getLastKnownPoint GeoPoint lastKnownPoint null Set up map Location lastKnownLocation this.locationManager.getLastKnownLocation LocationManager.GPS_PROVIDER ---1 Get the last known Location if lastKnownLocation null lastKnownPoint LocationHelper.getGeoPoint lastKnownLocation else lastKnownPoint LocationHelper.GOLDEN_GATE return lastKnownPoint The first thing to note with the MapViewActity is that it extends MapActivity O. Although we aren t focusing on the MapActivity details yet that will be covered in section 11.3 this extension is still important to note. Once we get the class started we declare member variables for LocationManager C and LocationProvider 0. In order to instantiate the LocationManager we use the Activity getSystemSer-vice String name method Q. LocationManager is a system service so we don t directly create it we let the system return it. After we have the LocationManager we also assign the LocationProvider we want to use with the manager s getProvider method 0. In this case we are using the GPS provider. We will talk more about the LocationProvider class in the next section. Once we have the manager and provider in place we use the onCreate method of our Activity to instantiate a MapController and set initial state for the screen 0. A .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.