TAILIEUCHUNG - Bắt Đầu Với Android (P.7)

Tham khảo tài liệu 'bắt đầu với android ()', 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ả | Page 277 Monday May 4 2009 3 11 PM CHAPTER 30 CREATING A SERVICE 277 application android label @string app_name activity android name .WeatherPlus android label @string app_name intent-filter action android name category android name intent-filter activity service android name .WeatherPlusService application manifest Since the service class is in the same Java namespace as everything else in this application we can use the shorthand dot-notation .WeatherPlusService to reference our class. If you wish to require some permission of those who wish to start or bind to the service add an android permission attribute naming the permission you are mandating see Chapter 35 for more details. Lobbing One Over the Fence Classic IPC is one-way the client calls functions on the service. It is possible through the creative use of AIDL to allow the service to call back into an activity. However this is a bit fragile as the service may not know if the activity is still around or if it has been killed off to free up some memory. An alternative approach first mentioned in Chapter 23 which discusses Intent filters is to have the service send a broadcast Intent that can be picked up by the activity . . . assuming the activity is still around and is not paused. We will examine the client side of this exchange in Chapter 31 for now let us examine how the service can send a broadcast. The theory behind the WeatherPlusService implementation is that the service gets tickled when the device or emulator position changes. At that point the service calls out to the Web service and generates a new forecast Web page for the activity to display. At the same time though the service also sends a broadcast to alert the activity that there is a page update available if it wants it. Here is the high-level implementation of the aforementioned flow private void updateForecast Location loc String url format .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.