TAILIEUCHUNG - Hướng dẫn lập trình cơ bản và nâng cao với Android 15

B6: Tạo BroadCast Receiver để nhận Intent mà Activity2 gửi tới - Tạo 1 file trong - Nội dung: Mã: package ; import import import import ; ; ; ; public class Receiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { long value = ("new value", -10) + 10; Toast toast = (context, "Broadcast Receiver catch an Intent" + " \n" + "The value is stored in the Intent is " + (value), ); (); } } 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 trong - Nội dung Mã package import import import import public class Receiver extends BroadcastReceiver @Override public void onReceive Context context Intent intent long value new value -10 10 Toast toast context Broadcast Receiver catch an Intent n The value is stored in the Intent is value 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 Mã xml version encoding utf-8 manifest xmlns android http apk res andro id package android versionCode 1 android versionName application android icon @drawable icon android label @string app_name activity android name .Activity1 android label @string app_name intent-filter action android name category android name 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 .

TỪ KHÓA LIÊN QUAN
Đã 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.