Oncreate() method

Why does the oncreate method doesn’t get called when written inside a activity/basic class.
But gets called when written independently in processing.

Ex: publc class A extends Activity
{
Public void onCreate(Bundle savedInstanceState)
{
//Doesn’t get called
}
}
I need this to complete my app…any help…
Check my previous post for detailed problem if needed.please helpp

Hey there Yash,

Could you please tidy up your code by using the preformatted text button? It’s the button shape like a </>. Also the piece of code you’ve showed so far contains several typos. For instance, Public shouldn’t start with a capital P. Working example:

A rectangle = new A (50, 50, 200, 100, "blabla");

void setup() {
  size(400, 400);
}

void draw() {
  background(240);
  rectangle.display();
  rectangle.onCreate();
}

public class Activity {
  int x, y, w, h;
  
  Activity (int x, int y, int w, int h) {
     this.x = x;
     this.y = y;
     this.w = w;
     this.h = h;
  }
  
  void display() {
     noStroke();
     fill(255, 0, 0);
     rect(this.x, this.y, this.w, this.h);
  }
}

public class A extends Activity {
  String s;
  
  A (int x, int y, int w, int h, String s) {
    super(x, y, w, h);
    this.s = s;
  }
  
  public void onCreate() {
    println(this.s);
  }
}
1 Like

Thanks for replying …there were no typos… i was just exemplifying with sample code.i request you to see my previous post and help me.

No you have understood my question wrong…it is regarding oncreate used to create main thread not a regular class.