I want some logic around a part of my code that can tell if I am using a certain theme. I would like to be able to tell if the current theme is equal to the theme with parent="Theme.Sherlock.NoActionBar".
I am wondering what the most efficient way to do this is as I can't figure out a simple way.
You can use the following code to get the name of the Theme and then compare it with the one you want to check.
public String returnThemeName()
{
PackageInfo packageInfo;
try
{
packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_META_DATA);
int themeResId = packageInfo.applicationInfo.theme;
return getResources().getResourceEntryName(themeResId);
}
catch (NameNotFoundException e)
{
return null;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With