| By Onkar Singh | Article Rating: |
|
| November 19, 2012 01:21 AM EST | Reads: |
531 |
SureFox for Android now comes with built-in set of Javascript APIs. Use them in a customized SureFox toolbar or embed in your web application to perform variety of actions such as navigating through pages or to launch an app directly from SureFox.
The APIs are written as window.surefox.<API_Name>
Following is a comprehensive list of SureFox APIs:
- load(URL): Loads the URL in the active screen of SureFox. URL is passed as a parameter to the API
window.surefox.load('http://www.google.com');
- openInNewTab(URL): Loads the URL in a new tab of SureFox. URL is passed as a parameter to the API
window.surefox.openInNewTab('http://www.google.com');
- back(): Navigate to the previous page in SureFox
window.surefox.back();
- forward(): Navigate to the next page in SureFox
window.surefox.forward();
- home(): Loads SureFox home page
window.surefox.home();
- refresh(): Refreshes current web page
window.surefox.refresh();
- stop(): Stops any ongoing loading activity in SureFox
window.surefox.stop();
- launch(packagename): Launches the application from SureFox. Only the package name of the application needs to be passed as a parameter to the API.
window.surefox.launch('com.android.contacts');
- launch(action,category,packagename,classname): Use this to launch a particular activity of an application from SureFox. The action, category, package name and class name of the application need to be passed as parameters to the API.
window.surefox.launch('android.intent.action.MAIN', 'android.intent.category.LAUNCHER', 'com.android.contacts', 'com.android.contacts.activities.PeopleActivity');
You can also use SureFox APIs to get and display battery status and perform actions based on the battery level. Following are the list of SureFox battery APIs:
- battery().level(): Returns the current battery level
window.surefox.battery().level()
- battery().charging(): Returns 'true' if battery is charging else returns a 'false'
window.surefox.battery().charging()
- battery().addEventListener("levelchange", "<user-defined-function>"): Used to add an event listener for battery level which can be used to call any function of your choice
window.surefox.battery().addEventListener("levelchange", "setLevel");
- battery().addEventListener("chargingchange", "<user-defined-function>"):
window.surefox.battery().addEventListener("chargingchange", "setStatus");
Sample HTML page for displaying use of SureFox APIs:
HTML Code for demo page:
<html>
<head>
<title>SureFox Javascript APIs</title>
<script type="text/javascript">
function setLevel(value) {
document.querySelector('#level').textContent = "Battery Level = " + value+"%";
}
function setStatus(value) {
document.querySelector('#status').textContent = "Charging: " + window.surefox.battery().charging();
}
function init() {
setLevel(window.surefox.battery().level() * 100);
setStatus(window.surefox.battery().charging());
window.surefox.battery().addEventListener("levelchange", "setLevel");
window.surefox.battery().addEventListener("chargingchange", "setStatus");
}
</script>
</head>
<body onload="javascript:init()">
<div id="container" style="background-color: #cccccc;">
<div style="float:right;">
Real Time Battery Status:<div id="status">(charging state unknown)</div>
<div id="level">(battery level unknown)</div>
</div>
<span onclick="window.surefox.home();"><button>Home</button></span>
<span onclick="window.surefox.back();"><button>Back</button></span>
<span onclick="window.surefox.forward();"><button>Forward</button></span>
<span onclick="window.surefox.refresh();"><button>Refresh</button></span>
<span onclick="window.surefox.stop();"><button>Stop</button></span>
<span onclick="window.surefox.launch('com.android.calendar');"><button>Calendar</button></span>
<span onclick="window.surefox.launch('android.intent.action.MAIN', 'android.intent.category.LAUNCHER', 'com.android.vending', 'com.android.vending.AssetBrowserActivity');"><button>Google Play</button></span>
<br />
<b><span onclick="window.surefox.load('http://www.42gears.com');">Click to visit 42Gears</span>
<br />
<span onclick="window.surefox.openInNewTab('http://www.google.com');">Click to launch Google(Open in new tab)</span></b>
</div>
</body> </html>
To know more about SureFox, click here
To learn more on how to secure and manage Android, iOS and Windows Mobile/CE devices efficiently, visit us at www.42gears.com
Read the original blog entry...
Published November 19, 2012 Reads 531
Copyright © 2012 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Onkar Singh
The author is the founder of 42Gears, developer of affordable Mobile Device Management tools.
- Cloud People: A Who's Who of Cloud Computing
- Enterasys Spotlights SDN's Impact on Traditional Networking in Upcoming Webinar
- NASA's Twitter Account Wins Back-To-Back Shorty Awards
- Basho Announces Open Source Riak CS and General Availability of Riak CS Enterprise v1.3
- Google Compute enters the IaaS market
- MicroStrategy Announces General Availability of MicroStrategy 9.3.1
- MicroStrategy Announces General Availability of MicroStrategy 9.3.1
- Cloud Expo | Maximizing the Small Things: Efficiencies for Cloud Hardware
- Google Submits Concessions to EC; Gets Sued in the UK
- GoBank Announces Timing of General Availability and National Distribution Relationships at FinovateSpring
- Global Mobile Security (mSecurity) Market 2013-2018
- RightScale Supports Windows Azure Infrastructure Services General Availability
- Cloud People: A Who's Who of Cloud Computing
- Enterasys Spotlights SDN's Impact on Traditional Networking in Upcoming Webinar
- NASA's Twitter Account Wins Back-To-Back Shorty Awards
- ChannelAdvisor Participates in Upcoming Retail Industry Conferences RBTE and Retail Week Live
- RetailMeNot Shoppers Trend Report: While Over 8 in 10 U.S. Residents Cite Affordability as Their Top Vacation Priority, a Majority (58%) Could Waste Hundreds of Dollars by Booking Travel a la Carte
- Basho Announces Open Source Riak CS and General Availability of Riak CS Enterprise v1.3
- Flexera Software App Portal Release Now Integrated with Software License Optimisation & Application Readiness Solutions to Ensure Optimised Software Spend and Continuous Compliance
- Enter for a Chance to Win an Apple iPad Mini During the Grand Opening of Silverleaf, Taylor Morrison’s Latest New Home Community in Denver
- How to Protect Your Facebook Account Before Graph Search is Public
- Oracle Appeals Java Decision
- Google Compute enters the IaaS market
- Enterprise Social Adoption Challenges
- Where Are RIA Technologies Headed in 2008?
- Cloud People: A Who's Who of Cloud Computing
- Dolphin Announces Open API With Over 50 Add-ons Including Dropbox and Wikipedia
- ManageWP Powers Over 100,000 WordPress Sites Within Three Months of Launch
- SEO/SEM Tips & Tricks: How and When Should You Submit Your Website to Google?
- Google Version 2.0: Googzilla - The Calculating Predator
- Google's Competitive Advantage: It Leverages "The Power of Free"
- Cloud Expo 2011 East To Attract 10,000 Delegates and 200 Exhibitors
- Google Space Launches at Heathrow Airport
- AOL To Enhance Video Search Engine by Adding RSS Feeds
- Ulitzer’s Amazing First 30 Days in Public Beta
- The World's Youngest "Google Entrepreneur" Is One Month Old

























