Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android theme name from theme ID

Tags:

I need to know the name of the current theme, I already have the theme's resource ID. Anybody knows how to get the current theme's name?

Thanks


Solution

public String getThemeName() {     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 223
d_r Avatar asked Apr 24 '12 17:04

d_r


1 Answers

Try using getResourceEntryName() or getResourceName() on Resources (typically retrieved via getResources()), depending on what you are aiming for.

like image 82
CommonsWare Avatar answered Oct 01 '22 18:10

CommonsWare