Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Context.startService(intent) or startService(intent)

What is the difference between Context.startService(intent) and startService(intent) and does it matter which one is used?

like image 653
mnish Avatar asked Jan 22 '23 01:01

mnish


2 Answers

There is only one startService() method. startService() is a method on the Context class, available to all subclasses of Context, like Activity or Service.

like image 66
CommonsWare Avatar answered Jan 30 '23 15:01

CommonsWare


As Commonsware said there is only one startService(). That is Context.startService(intent).

Your main activity program itself is an instance of Context and you do not need to explicity call the method (startService) with a Context.

It is like calling a method of a class within the class itself.

like image 43
Jay Avatar answered Jan 30 '23 13:01

Jay