Unfortunately I don't believe there's a way to get at this through Apex code. There is a describeTabs method in the web services API that looks like it would give you the information you are after, but I've not been able to find an equivalent in Apex.
public static string getCurrentApplication()
{
// Get tab set describes for each app
List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
for(Schema.DescribeTabSetResult tsr : tabSetDesc)
if (tsr.isSelected()) return tsr.getName();
return null;
}
Unfortunately I don't believe there's a way to get at this through Apex code. There is a describeTabs method in the web services API that looks like it would give you the information you are after, but I've not been able to find an equivalent in Apex.