只是出于好奇。如何从构造函数不需要参数的 Class 创建一个新类?这是一个例子:
public static BroadcastReceiver startBroadcastReceiver(Context context, Class<?> receiverClass, String receiverTag) {
BroadcastReceiver receiver = null;
IntentFilter intentFilter = new IntentFilter(receiverTag);
receiver = new receiverClass(); // <---- What's the correct syntax?
if (receiver != null && intentFilter != null) {
context.registerReceiver(receiver, intentFilter);
}
return receiver;
}
我是这样称呼它的:
MyTools.startBroadcastReceiver(context, MyBroadcastReceiver, MyBroadcastReceiver.TAG);
提前致谢。