Đang chuẩn bị liên kết để tải về tài liệu:
Hướng dẫn lập trình cơ bản và nâng cao với Android 15

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

B6: Tạo BroadCast Receiver để nhận Intent mà Activity2 gửi tới - Tạo 1 file Receiver.java trong at.exam - Nội dung: Mã: package at.exam; import import import import android.content.BroadcastReceiver; android.content.Context; android.content.Intent; android.widget.Toast; public class Receiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { long value = intent.getLongExtra("new value", -10) + 10; Toast toast = Toast.makeText(context, "Broadcast Receiver catch an Intent" + " \n" + "The value is stored in the Intent is " + String.valueOf(value), Toast.LENGTH_LONG); toast.show(); } } Code không hề khó hiểu, và mình cũng đã add comment. Chỉ cần lưu ý ở đây là Toast là. | Hướng dẫn lập trình CO bẩn với Android Part 15 B6 Tạo Broadcast Receiver để nhận Intent mà Activity2 gửi tới - Tạo 1 file Receiver.java trong at.exam - Nội dung Mã package at.exam import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.widget.Toast public class Receiver extends BroadcastReceiver @Override public void onReceive Context context Intent intent long value intent.getLongExtra new value -10 10 Toast toast Toast.makeText context Broadcast Receiver catch an Intent n The value is stored in the Intent is String.valueOf value Toast.LENGTH_LONG toast.show Code không hề khó hiểu và mình cũng đã add comment. Chỉ cần lưu ý ở đây là Toast là lớp để hiển thị một thông báo đơn giản trong 1 khoảng thời gian cố định và ko thể thay đổi thời gian này T_T why chỉ có thể chọn giữa LENGTH_sHoRT với LENGTH_LONG B7 Bổ sung thêm thông tin về component mới vào AndroidManifest.xml Mã xml version 1.0 encoding utf-8 manifest xmlns android http schemas.android.com apk res andro id package at.exam android versionCode 1 android versionName 1.0 application android icon @drawable icon android label @string app_name activity android name .Activity1 android label @string app_name intent-filter action android name android.intent.action.MAIN category android name android.intent.category.LAUNCHER intent-filter activity activity android name .Activity2 activity receiver android name .Receiver receiver application uses-sdk android minSdkVersion 3 manifest Sffie 1 11 PM Explicit Intent Example Activity 1 - Send .

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.