Reputation: 55
I am calling a class's member function from another class. So,I am creating an object of the class for which i have to call constructor. Within that constructor, I need to call onc reate method of my activity class.how can I do it?
Upvotes: 0
Views: 1350
Reputation: 5643
Well,i presume u r trying to call a constructor in an activity.If that is the case then some thing is wrong in the way u have designed ur project.For more details check out these links Creating an object of Android Activity class and Android - Activity Constructor vs onCreate
Upvotes: 0
Reputation: 8242
All method's of Activity class should be called within activity only . write your own methods for whatever operation you need to perform and pass data from other Activity/class by various data transfer algorithms .
Upvotes: 0
Reputation: 8302
Do not call onCreate from your constructor. The system itself will call onCreate for you.
Take a look at the Activity Lifecycle for more information of how onCreate is called.
Upvotes: 5