benCoding.Android.Tools
A collection of utilities designed to make working with Titanium on Android alittle easier.
<h1>Platform</h1> The Platform proxy provides access to several helpful Android APIs that are currently not available in the Titanium SDK.
<h2>Setup</h2>
<pre><code> var tools = require('bencoding.android.tools'); </code></pre>
<h2>Methods</h2>
<b>intentAvailable</b>( Ti.Android.Intent ) This method checks if there is an app on your device that can handle a specific intent.
<b>Parameters</b> intent : Ti.Android.Intent Ti.Android.Intent to be used in checking for availability.
<b>Returns</b> Boolean
<b>Example</b> <pre><code> var platformTools = tools.createPlatform(); var intent = Ti.Android.createIntent({ action: Ti.Android.ACTION_VIEW, type: "application/pdf", data: session.tempFile.nativePath });
if(platformTools.intentAvailable(intent)){
try {
Ti.Android.currentActivity.startActivity(intent);
} catch(e) {
Ti.API.debug(e);
alert('Something went wrong');
}
}else{
alert("Please go to the Google Play Store and download a PDF reader");
}
</code></pre>
<b>restartApp</b> This method restarts your Titanium app
<b>Parameters</b> None
<b>Returns</b> None
<b>Example</b> <pre><code> var platformTools = tools.createPlatform(); //Restarts your Titanium App platformTools.restartApp();
</code></pre>
<b>exitApp</b> This method closes your Titanium app
<b>Parameters</b> None
<b>Returns</b> None
<b>Example</b> <pre><code> var platformTools = tools.createPlatform(); //Restarts your Titanium App platformTools.exitApp();
</code></pre>
<b>isAirplaneModeOn</b> This method returns a boolean if the device is in airplane mode
<b>Parameters</b> None
<b>Returns</b> Boolean (true/false)
<b>Example</b> <pre><code> var platformTools = tools.createPlatform(); var onPlane = platformTools.isAirplaneModeOn(); alert('Your device is in airplane mode: ' + (onPlane ? 'Yes' :'No'));
</code></pre>