android - this keyword as parameter to a new Intent -
from android documentation:
public intent (context packagecontext, class<?> cls) parameters packagecontext context of application package implementing class. cls component class used intent.
correct me if wrong:
a context of application package implementing class.
means package contains class want start.this
shouldn't work(but works, why?), becausethis
refers current activity, notapplication package
says in documentation.
a context of application package implementing class. means package contains class want start.
here, "application package", cases, is referring app.
this shouldn't work
yes, should.
this refers current activity, not application package says in documentation.
assuming current activity , activity started both in same app, this
works fine, "a context of application package implementing class". this
not work if trying start activity other app, in case use implicit intent
pattern, using action string (e.g., action_view
) instead of context
, java class.
Comments
Post a Comment