The view of my custom object is overwritten by a Visualforce page for my desktop users. This VF page should not be visible for my mobile users.
Before I render my VF page, I check the device to redirect my mobile users like this:
VF page:
<apex:page standardController="Travel__c" extensions="TravelCtrlExt" action="{!doDeviceDetection}">
Controller:
public PageReference doDeviceDetection() {
PageReference result = null;
Boolean isMobileDevice = false;
String userAgent = ApexPages.currentPage().getHeaders().get('USER-AGENT');
if( (userAgent.contains('iPhone')) || (userAgent.contains('iPad')) || (userAgent.contains('Android')) ) {
isMobileDevice = true;
}
if( isMobileDevice ) {
result = stdCtrl.view();
result.getParameters().put('nooverride', '1');
}
return result;
}
This should redirect my mobile users to the standard view of the record, but it doesn't work. The mobile users get stuck in a loop.