可以通过使用Bundle将多个参数封装为一个参数。下面是一个示例代码:
// 发送广播时创建一个Bundle Bundle extras = new Bundle(); extras.putString("param1", "value1"); extras.putInt("param2", 123);
// 将Bundle作为参数添加到Intent中 Intent intent = new Intent("com.example.ACTION_UPDATE"); intent.putExtras(extras);
// 在广播接收器中提取参数 public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); String param1 = extras.getString("param1"); int param2 = extras.getInt("param2"); // 处理参数... }