How do I get the name of a service programmatically in Android?
Let’s say I’ve this piece of code:
public class MainActivity extends Activity {
private MyService mService;
Let’s say I want to toast the name of the service which could be like com.example.MyService.
Is it possible to get it from mService variable?
For now, I got it using MyService in this way
MyService.class.getName()
If you want to get class name dynamically, you can use:
If you want to get class name only, without package, you can use: