This will detect if you are in Phonegap (vs. desktop browser)

761 views
Skip to first unread message

JJBigThoughts

unread,
Apr 22, 2009, 10:29:10 AM4/22/09
to phonegap
Maybe this will help someone. Maybe there is a more elegant way of
doing this?

// Motivation: I made a web app with which I wanted to use the same
code on the web and in phonegap. I'm using this to turn on/off
corresponding behavior, like telling the web user about the phonegap
version
// @Authors: JJBigThoughts
function isPhonegap() {
if (window.Device !== undefined) {
return true;
} else {
return false;
}
}

David Orchard

unread,
Apr 27, 2009, 3:10:56 PM4/27/09
to phonegap
Could you try some of the phonegap specific calls and if they don't
work then you know? All of the JS calls to gap: ought to fail right?

Dave

Joe Bowser

unread,
Apr 27, 2009, 3:30:11 PM4/27/09
to phon...@googlegroups.com
I think that the window.Device testing is probably the best way to deal with this.  Android doesn't have any calls to gap: and I don't think that Blackberry does either.  That's to be taken into consideration if you're looking to port this app to all the supported platforms.

Joe
Reply all
Reply to author
Forward
0 new messages