[SalesForce] Detecting Lightning User Experience

This Salesforce Documentation suggests that we can detect which User Interface is being displayed by using the $User.UITheme and $User.UIThemeDisplayed global variables and the UserInfo.getUiTheme() and the UserInfo.getUiThemeDisplayed() Apex methods. In my org, I have enabled the Lightning experience for my user and switched over to the new UI. However, when I try to detect the interface using either in Visualforce using the global variables on through the Developer Console using the Apex methods, it keeps returning 'Theme3' and not 'Theme4d' as is expected. Has anyone else run into this issue? Are there more steps to Enable Lightning that I'm missing?

Best Answer

This was just user error on my part. Although I had Lightning enabled, I had not switched to it when I was trying to detect the UI Theme. Once I switched to the Lightning view, it was detecting the UI Theme correctly.