I'm trying to detect on a visualforce page that is the page opened in a classic or Lightning view in Salesforce. For this I'm using "$User.UITheme" and "$User.UIThemeDisplayed" on the visualforce page and it is always return "Theme3". Also, when I use the UserInfo.getUiThemeDisplayed() method in the controller and display on the page it shows "Theme3" instead of "Theme4d" even if I'm in the lightning experience.
Here is the controller code:-
public with sharing class CheckUITheme {
public String themeViewed{get;set;}
public CheckUITheme(){
themeViewed = UserInfo.getUiThemeDisplayed();
System.debug('>>>>>'+UserInfo.getUiThemeDisplayed());
}
}
Here is the Visualforce page code:-
<apex:page controller="CheckUITheme">
<h1>Congratulations</h1> This is your new Page
>>>>>>>>{!themeDisplayed}>>>>>>>>>
>>>>>>>>{!themeViewed}>>>>>>>>> {!$User.UITheme} {!$User.UIThemeDisplayed}
</apex:page>
and the output which I get is :-
Congratulations This is your new Page >>>>>>>Theme3>>>>>>>>> >>>>>>>Theme3>>>>>>>>> Theme3 Theme3
What wrong m I doing here or is there a bug in the Salesforce method?
37.0
to42.0