I am looking at a tutorial and see the author using intent.setClass() to get the to the next Activity and then on the same page he uses intent.setComponent()
to get to the next Activity.
So what is the difference and what is the advantage in using any of them?
Other than different parameters.
intent.setcomponent()
= Explicitly set the component to do the handling of the intent.
intent.setClass()
= Convenience for calling setComponent(ComponentName) with the name returned by a Class object.
another difference is that .setComponent()
can find the appropiate class for you.
*From android Developers*
SetComponent Android Dev
You should only set this value when you know you absolutely want a specific class to be used; otherwise it is better to let the system find the appropriate class so that you will respect the installed applications and user preferences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With