Issue
I have a class REG that extends Activity
: it has a window, buttons, actions, etc. I know how to open the activity via an Intent
.
Yet, I could also make a new instance of the class:
new REG(...)
When/why I should use one over the other?
Solution
Yet, I could also make a new instance of the class
Not really.
When/why I should use one over the other?
You always start activities via startActivity()
, whether you are calling it yourself or something else is calling it on your behalf.
Using the constructor creates the object, but it will not be properly initialized, nor will it show a UI. Never create an instance of an activity (or service or ContentProvider
) directly yourself.
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.