There are many ways to start another activity.
The most of the overloading methods requires you to pass a context.
But when using componentName to launch an activity using
public Intent setComponent (ComponentName component)
and this constructor for ComponentName
ComponentName(String pkg, String cls)
You see above, I am able to launch an activity WITHOUT using any Context argument
But it must use some “context” somehow internally, am I right? If so, which context? Application one or the activity one?
Does this mean that every time I use this two methods (above), I do not need to worry about memory leak becuase I am not passing any context around??
Thanks
You don’t have to worry about memory leaks in either case, but it’s good that you’re keeping an eye on where you’re passing Context objects. Intent simply uses the Context parameter to look up your package name when you use the
Intent(Context, Class)constructor orsetClass(Context, Class)method. They’re just convenience methods.