Is there a way for a Library to know the package name of the application using it?
Is there a way开发者_如何学编程 for any class in a library (could be activity, view or any other class that may have access to a "magic" method) to know or inquire the package name of the application using it?
If so, how?
It would be great to have this ability at run-time, but having this ability in build/compile time would be good as well.
If you have a Context of the application (you can have that passed into your library in a constructor, for example), you can do this:
context.getPackageName();
EDIT: definitely not at build/compile time.
精彩评论