Custom constructor

On page no. 102 it says that “you cannot use a custom constructor with an activity subclass” …
What does it actually means ? Please explain with help of an example.

Thanks in advance.

This means that you can’t do the following:

public class MyActivity extends Activity {

  public MyActivity(Question question) {
    
  }
  
}

So, now if you create an instance of this class, you would say:

new MyActivity(question)

You can’t do this because you never create activities yourself. Android is responsible for creating activities. When Android tries to create MyActivity in this example, it won’t be able to. Android won’t care about the question parameter to the activity.

1 Like