A apologies for a very trivial question.
I want to understand what is difference between the following calls when invoked from a fragment:-
- context?.startService(Intent(context, SomeService::class.java))
- requireActivity().startService(Intent(requireActivity(), SomeService::class.java))
The most obvious difference that I can think about is that if the fragment is not attached to an activity when the Point 2 call is made, then the app would crash.
To avoid such crashes I can use the call mentioned in Point 1.
That being said, is there any reason then that justifies the starting of a service as described in point 2?