为什么我们在 Android 中扩展 IntentService class 时在构造函数中传递 super((String)IntentServiceClassName )
Why we pass super((String)IntentServiceClassName ) in constructor while extending IntentService class in Android
为什么我们在 Android.
中扩展 IntentService class 时在构造函数中传递 super((String)IntentServiceClassName )
为什么我们使用空的构造函数。为什么名称 >??
public class MyService extends IntentService {
public static final int STATUS_RUNNING = 0;
public static final int STATUS_FINISHED = 1;
public static final int STATUS_ERROR = 2;
private static final String TAG = "MyService";
public MyService() {
super(MyService.class.getName());
//or super("MyService");
}
因为我们也必须实例化父class的构造函数来通知它它的子class已经创建...
在java中,如果您不提供 super 作为第一条语句,编译器会自动将此语句附加为编译后的第一行...
为什么我们在 Android.
中扩展 IntentService class 时在构造函数中传递 super((String)IntentServiceClassName )为什么我们使用空的构造函数。为什么名称 >??
public class MyService extends IntentService {
public static final int STATUS_RUNNING = 0;
public static final int STATUS_FINISHED = 1;
public static final int STATUS_ERROR = 2;
private static final String TAG = "MyService";
public MyService() {
super(MyService.class.getName());
//or super("MyService");
}
因为我们也必须实例化父class的构造函数来通知它它的子class已经创建...
在java中,如果您不提供 super 作为第一条语句,编译器会自动将此语句附加为编译后的第一行...