Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if two themes are equal?

Tags:

android

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.

like image 407
hwrdprkns Avatar asked Dec 12 '25 12:12

hwrdprkns


1 Answers

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;
    }
}
like image 127
Swayam Avatar answered Dec 15 '25 02:12

Swayam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!