Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)Techacademy Software
Android là một hệ điều hành dành cho thiết bị di động như điện thoại, máy tính bảng, máy đọc sách.
Android cung cấp framework ứng dụng ở dạng component.
Hỗ trợ trình duyệt web, đồ họa 2D – 3D, các định dạng đa phương tiện, bluetooth.
Viewmore: www.techacademy.vn - Techacademy VietNam - Techacademy SoftWare
Android là một hệ điều hành dành cho thiết bị di động như điện thoại, máy tính bảng, máy đọc sách.
Android cung cấp framework ứng dụng ở dạng component.
Hỗ trợ trình duyệt web, đồ họa 2D – 3D, các định dạng đa phương tiện, bluetooth.
Viewmore: www.techacademy.vn - Techacademy VietNam - Techacademy SoftWare
Slide bài giảng lập trình Android DTU - Phần 5 (Broadcastreceiver)Techacademy Software
Android là một hệ điều hành dành cho thiết bị di động như điện thoại, máy tính bảng, máy đọc sách.
Android cung cấp framework ứng dụng ở dạng component.
Hỗ trợ trình duyệt web, đồ họa 2D – 3D, các định dạng đa phương tiện, bluetooth.
Viewmore: www.techacademy.vn - Techacademy VietNam - Techacademy SoftWare
Android là một hệ điều hành dành cho thiết bị di động như điện thoại, máy tính bảng, máy đọc sách.
Android cung cấp framework ứng dụng ở dạng component.
Hỗ trợ trình duyệt web, đồ họa 2D – 3D, các định dạng đa phương tiện, bluetooth.
Viewmore: www.techacademy.vn - Techacademy VietNam - Techacademy SoftWare
Cookie Seminar | 5 juni | Damian Scragg | Evidonclickdistrict
This document discusses regulatory requirements around online tracking in the US and EU and how Evidon helps companies comply. It notes that the EU ePrivacy Directive requires notice and consent for data collection, and that standards of consent vary but implied consent through banners is generally accepted. The document provides examples of how different companies implement consent banners and controls. It emphasizes that privacy regulations aren't going away and are likely to become stricter, so companies should work to comply through self-regulation to avoid harsher government enforcement.
This tutorial explains how to change the icon of an Android application, including locating the drawable files, adding a new icon image, cleaning and running the project to display the updated icon both on the home screen and within the application itself. Key steps are saving an icon image like PNG to the drawable folder, cleaning the project, updating the icon name in the manifest, and re-running the app on an emulator to see the changed icon.
University of California, Berkeley Technology Transfer and IP CommercializationOphelia Yeung
The Office of Intellectual Property and Industry Research Alliances (IPIRA) at UC Berkeley manages the university's intellectual property portfolio and supports industry-university research collaborations. IPIRA includes the Industry Alliances Office (IAO), which fosters research partnerships with over 800 companies, and the Office of Technology Licensing (OTL), which licenses UC Berkeley's intellectual property and has generated over $200 million in revenue. IPIRA helps translate UC Berkeley research into commercial products and societal benefits through licensing agreements and the formation of over 150 startup companies.
Lập trình Android cơ bản bằng tiếng Việt,Lap trinh Android co ban bang tieng Viet, Học lập trình Android, Hoc lap trinh Android | Trung tâm đào tạo lập trình Android Trí Tuệ Việt là trung tâm đào tạo Android uy tín, chất lượng tại tpchm, hà nội
Cookie Seminar | 5 juni | Damian Scragg | Evidonclickdistrict
This document discusses regulatory requirements around online tracking in the US and EU and how Evidon helps companies comply. It notes that the EU ePrivacy Directive requires notice and consent for data collection, and that standards of consent vary but implied consent through banners is generally accepted. The document provides examples of how different companies implement consent banners and controls. It emphasizes that privacy regulations aren't going away and are likely to become stricter, so companies should work to comply through self-regulation to avoid harsher government enforcement.
This tutorial explains how to change the icon of an Android application, including locating the drawable files, adding a new icon image, cleaning and running the project to display the updated icon both on the home screen and within the application itself. Key steps are saving an icon image like PNG to the drawable folder, cleaning the project, updating the icon name in the manifest, and re-running the app on an emulator to see the changed icon.
University of California, Berkeley Technology Transfer and IP CommercializationOphelia Yeung
The Office of Intellectual Property and Industry Research Alliances (IPIRA) at UC Berkeley manages the university's intellectual property portfolio and supports industry-university research collaborations. IPIRA includes the Industry Alliances Office (IAO), which fosters research partnerships with over 800 companies, and the Office of Technology Licensing (OTL), which licenses UC Berkeley's intellectual property and has generated over $200 million in revenue. IPIRA helps translate UC Berkeley research into commercial products and societal benefits through licensing agreements and the formation of over 150 startup companies.
Lập trình Android cơ bản bằng tiếng Việt,Lap trinh Android co ban bang tieng Viet, Học lập trình Android, Hoc lap trinh Android | Trung tâm đào tạo lập trình Android Trí Tuệ Việt là trung tâm đào tạo Android uy tín, chất lượng tại tpchm, hà nội
Hệ thông phân tán
Dạng đề cập nhật mới nhất vào ngày: 29/6/2021 tại đây:
Giải thuật đồng thuận phân tán.
Remarkable Stuff to note 'em down.
#PTIT
Sourcecode LINK: shorturl.at/hyS26
This document provides an overview of Android malware. It begins with background on Android architecture, including that Android applications are packaged in APK files which contain code, resources, and an AndroidManifest file. It discusses Android application components like Activities and Services. It then covers the Android security model, permissions, and the Dalvik virtual machine. The document demonstrates reversing an APK file and outlines steps for creating a basic malware. It concludes with discussions of notable Android malware examples and opportunities for mobile application penetration testing.
The document describes two universal I/O modules, the TXM1.8U and TXM1.8U-ML. Both modules have 8 inputs/outputs that can be individually configured as digital inputs, analog inputs, or analog outputs. The TXM1.8U-ML additionally includes an LCD display and local override facility. The modules have compact DIN rail housing, LED status indicators, and terminal bases that allow easy wiring and replacement of modules without rewiring.
Mod Two Homology and Cohomology (Jean Claude)Justin Hoang
This chapter introduces simplicial (co)homology with coefficients in Z2. It defines simplicial complexes and simplicial (co)chains. It establishes the Kronecker pairing between simplicial homology and cohomology and provides some initial computations, including for surfaces. It also introduces exact sequences, relative (co)homology, Mayer-Vietoris sequences, and exercises related to simplicial (co)homology.
2. Tổng quan
• BroadcastReceiver (có thể gọi là Receiver là
một trong bốn loại thành phần trong ứng dụng
Android. Chức năng dùng để nhận các sự kiện
mà các ứng dụng hoặc hệ thống phát đi.
• Có 2 cách phát-nhận đó là:
– Không có thứ tự: receiver nào đủ điều kiện thì
nhận hết, không phân biệt và cũng tách rời nhau.
– Có thứ tự: receiver nào đăng ký ưu tiên hơn thì
nhận trước, và có thể truyền thêm thông tin xử lý
cho các receiver sau.
3. Lifecycle
• Thực ra lifecycle của BroadcastReceiver chỉ
có duy nhất một phương thức onReceive().
– Khi có sự kiện mà BroadcastReceiver đã đăng ký
nhận được phát đi, thì phương thức onReceive()
của BroadcastReceiver đó sẽ được gọi.
– Sau khi thực thi xong phương thức này, lifercycle
của Receiver kết thúc.
4. Lưu ý khi sử dụng
• Ngay khi onReceive() kết thúc, hệ thống coi
như receiver đã không còn hoạt động và có thể
kill process chứa receiver này bất cứ lúc nào.
Tránh xử lý các code quá lâu trong onReceive().
Không có xử lý bất đồng bộ, chờ callback… trong
Receiver (cụ thể như hiển thị Dialog, kết nối
service…)
5. Một số broadcast thông dụng
• Báo hệ thống khởi động xong
• Báo pin có sự thay đổi
• Báo có package mới cài vào hoặc xóa đi
• Báo tắt máy
• Báo cắm sạc, rút sạc…
Xem thêm tại đây, mục Standard Broadcast
Actions
6. Một số broadcast khác
• Thông báo tin nhắn tới
• Thông báo cắm, rút thẻ nhớ
• Thông báo có cuộc gọi đi
• Và các bạn có thể định nghĩa broadcast cho
riêng mình (mục tiêu chính của việc này giúp
bạn có thể liên lạc giữa các ứng dụng bạn viết
hoặc thông báo một sự kiện liên quan đến ứng
dụng của bạn với các ứng dụng khác)
7. onReceive()
• Phương thức này được gọi khi có sự kiện
tương ứng được phát đi. Ở trong phương thức
này, ta thấy truyền vào context và intent.
– Vì Receiver không kế thừa từ Context nên cần
truyền context mà receiver này đang chạy vào.
Thứ nhất, để có thể xử lý các phương thức yêu cầu
truyền thêm Context, thứ 2, để sử dụng các
phương thức của lớp Context. (còn nữa hay không thì các
bạn giúp mình luôn nhé)
8. onReceive()
– Intent được truyền vào sẽ có đầy đủ thông tin như
sự kiện nào mà receiver này đăng ký đã xảy ra dẫn
đến onReceive() được gọi. Có gửi kèm thông tin gì
hoặc dữ liệu gì hay không. Xem các api:
Intent.getAction()
Intent.get…Extra(String dataName)
9. Ví dụ BootReceiver
• Các bạn có thể đăng ký nhận sự kiện hệ thống
vừa khởi động xong để có thể làm việc gì đó
ngay, hoặc vận hành song song với hệ thống…
• Ta sẽ đăng ký nhận sự kiện BOOT_COMPLETED,
sau đó sẽ gọi một dialog lên hiển thi lời chào.
• Khi hệ thống khởi động xong sẽ xuất một
dialog chào user
10. Ví dụ BootReceiver
• Trong manifest, cần đăng ký permission được
nhận sự kiện này
<uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
• Khai báo receiver bên trong thẻ application
<receiver android:name=".BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
11. Ví dụ BootReceiver
• Ở đây ta khai báo trong manifest là ứng dụng
có một receiver tên là BootReceiver (slide kế
sẽ thấy).
• BootReceiver này đăng ký nhận sự kiện “hệ
thổng khởi động hoàn tất”.
• Dĩ nhiên, muốn nhận sựu kiện dạng này thì
cần phải đăng kí trước để với hệ thống qua
permission để user được biết.
12. Ví dụ BootReceiver
• Tạo một class mới trong source, tên là
BootReceiver kế thừa BroadcastReceiver.
• Implement lại phương thức onReceive() với
code như sau:
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
Intent helloIntent = new Intent(context, HelloBootActivity.class);
helloIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(helloIntent);
}
13. Ví dụ BootReceiver
• Giải thích một chút: vì Receiver không kế thừa
context nên khi tạo intent mới không truyền
this vô được, thay vào đó truyền cái context đã
được gửi kèm.
• Vì không ở trong 1 activity mà đang ở trong 1
receiver, và một số vấn đề liên quan tới task
trong Android nên bạn phải thêm cờ
Intent.FLAG_ACTIVITY_NEW_TASK (bạn chỉ có
thể ko dùng cờ này khi bạn gọi startActivity()
từ một activity)
14. Ví dụ BootReceiver
• Đọc tới đây chắc các bạn hiểu ngay là ứng dụng
có một activity tên là HelloBootActivity, activity
này sẽ chỉ hiển thị dạng dialog, và sẽ không được
start bằng cách bấm vào icon trên màn hình. Vì
thế, khai báo trong manifest như sau:
<activity android:name=".HelloBootActivity"
android:theme="@android:style/Theme.Dialog">
</activity>
• Còn activity chỉ hiển thị một cái TextView là
“Chào bạn, mới khởi động xong” và một cái
Button để bấm vào đó thì đóng activity, các bạn
hoàn tất nhé.
15. Phát sự kiện
• Các bạn có thể phát một sự kiện cho các
receiver khác nhận dạng như sau:
Intent intent = new
Intent("org.multiuni.android.BROADCAST_DEMO");
sendBroadcast(intent);
• Hoặc:
sendOrderedBroadcast(intent, "permission tùy ý hoặc null");
• Ngoài ra còn có một số các gửi broadcast
khác, các bạn tham khảo thêm trong class
ContextWrapper nhé
16. Bài tập yêu cầu
1. Làm ứng dụn BootReceiver vừa rồi.
2. Lên g-android, tìm code mẫu về chuyển
hướng cuộc gọi, làm cái đó (cũng receiver)
3. Viết 2 ứng dụng, ứng dụng A nhập vào một
chuỗi rồi phát đi một sự kiện tự định nghĩa,
kèm theo chuỗi đó. Ứng dụng B nhận sự kiện
đó và hiển thị một Toast có nội dung là chuỗi
nhận được.