# Oncreate() method

**URL:** <https://discourse.processing.org/t/oncreate-method/14388>\
**Category:** Processing for Android\
**Created:** [October 3, 2019, 6:49am UTC](https://discourse.processing.org/t/oncreate-method/14388 "2019-10-03T06:49:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 3, 2019, 6:49am UTC](https://discourse.processing.org/t/oncreate-method/14388/1 "2019-10-03T06:49:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [October 3, 2019, 8:56am UTC](https://discourse.processing.org/t/oncreate-method/14388/2 "2019-10-03T08:56:33Z")

</div>

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:

```auto
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);
  }
}

```

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 3, 2019, 9:30am UTC](https://discourse.processing.org/t/oncreate-method/14388/3 "2019-10-03T09:30:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yash](https://avatars.discourse-cdn.com/v4/letter/y/f17d59/32.png) [@Yash](https://discourse.processing.org/u/Yash)\
**Post date:** [October 3, 2019, 9:32am UTC](https://discourse.processing.org/t/oncreate-method/14388/4 "2019-10-03T09:32:11Z")

</div>

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