How to Get Package Name of Source Class File in Android ?

前端 未结 5 2217
礼貌的吻别
礼貌的吻别 2020-12-17 18:55

I am using only one project to port lite and full versions for that I am just updating Manifest file package names.

My project structure is like this

My Ap

5条回答
  •  执念已碎
    2020-12-17 19:57

    Simple example of some class NotificationListener:

    Timber.d(NotificationListener.class.getPackage().getName());
    Timber.d(NotificationListener.class.getSimpleName());
    Timber.d(NotificationListener.class.getName());
    

    Output:

    D/PermissionsUtil: com.example.receivers
    D/PermissionsUtil: NotificationListener
    D/PermissionsUtil: com.example.receivers.NotificationListener
    

提交回复
热议问题