lập trình android (phần 7)

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 LocationManager Instantiate LocationManager Context. LOCATION_SERVICE 1 system service LocationManager. GPS_PROVIDER n Assign GPS LocationListeners omitted here for brevity LocationProvider GeoPoint lastKnownPoint 10 lastKnownPoint 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 ---1 Get the last known Location if lastKnownLocation null lastKnownPoint lastKnownLocation else lastKnownPoint 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 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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
187    1    1    22-05-2024
Đã 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.