lopi lopi - 2 months ago 6
Android Question

GetPackageName including Class name of Context

This is how I get Package name

context.getPackageName();
.

This is how I get Class name
context.getClass().getSimpleName());
.

Then how can I get packageName including class name in one line?
i.e
com.package.MainActivity

Answer

Simply leave out Simple: context.getClass().getName()

This should work.

Alternatively if you insist on using context.getPackageName() and/or context.getClass().getSimpleName() consider context.getPackageName() + context.getClass().getSimpleName().