BlackBerry Tablet OS 7 API with Adobe Flash Builder 4.5


BlackBerry Tablet OS 7 is an interactive Operating System support used to build games,Rich applications apart from native BlackBerry App, to start with exploring BlackBerry Tablet OS API with Adobe Flash Builder 4.5, the skill is more perfect.

Here is some sort of APIs for BlackBerry Tablet OS 7:

  • Accelerometer
  • GPS
  • Camera UI
  • Camera Roll
  • MultiTouch
  • MicroPhone
  • Busy Indicator.

Lets start with Each API ‘s code Sample:

xml version=”1.0″ encoding=”utf-8″?>

<s:Application

 xmlns:fx=”http://ns.adobe.com/mxml/2009

xmlns:s=”

library://ns.adobe.com/flex/spark

applicationComplete=”application1_applicationCompleteHandler(event)”

>

<fx:Script>


CDATA[

import flash.sensors.Accelerometer;

import mx.events.FlexEvent;

privatevar accelerometer:Accelerometer;

protectedfunction application1_applicationCompleteHandler(event:FlexEvent):void {

if(Accelerometer.isSupported== true) {

accelerometer =

new Accelerometer();

accelerometer.addEventListener(AccelerometerEvent.UPDATE,handleUpdate);

}

else {

status.text=

“Accelerometer not supported”;

}

}

privatefunction handleUpdate(event:AccelerometerEvent):void {

info.text =

“Updated:” + new Date().toTimeString() +“\n\n”


+

“acceleration X:” + event.accelerationX + “\n”


+

“acceleration Y:” + event.accelerationY + “\n”


+

“acceleration Z:” + event.accelerationZ;

}

]]>

</fx:Script>


<fx:Declarations>


<!– Place non-visual elements (e.g., services, value objects) here –>


</fx:Declarations>


<s:Label id=”status” text=”Shake your Phone a bit” top=”10” width=”100%” textAlign=”center/>

TextArea id=”info” width=”100%” height=”200” top=”40” editable=”false/>


<fx:Declarations>


<!– Place non-visual elements (e.g., services, value objects) here –>


</fx:Declarations>


</s:Application>

Set the Permission settings of BlackBerry Tablet OS as in BlackBerry-Tablet.xml file:

<

permission>access_shared</permission>


<permission>record_audio</permission>


<permission>read_geolocation</permission>


<permission>use_camera</permission>


<permission>access_internet</permission>


<permission>play_audio</permission>


<permission>post_notification</permission>


<permission>set_audio_volume</permission>


<permission>read_device_identifying_information</permission>

</

qnx>

  •  GPS : The GPS API stands for Global Positioning System. GPS is a space-based satellite navigation system that sends reliable location information to your handheld device.

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009

xmlns:s=”

library://ns.adobe.com/flex/spark

applicationComplete=”application1_applicationCompleteHandler(event)”

>


<fx:Script>


<![CDATA[

import flash.sensors.Geolocation;

import mx.events.FlexEvent;

privatevar geolocation:Geolocation;

protectedfunction application1_applicationCompleteHandler(event:FlexEvent):void


{

if(Geolocation.isSupported == true) {

geolocation =

new Geolocation();

geolocation.addEventListener(GeolocationEvent.UPDATE,handleLocationRequest);

}

else {

status.text =

“Geolocation feature not supported”;

}

}

privatefunction handleLocationRequest(event:GeolocationEvent):void {

var mph:Number = event.speed*2.23693629;

var kph:Number = event.speed*3.6;

info.text=

“Updated:” + new Date().toTimeString()+“\n\n”


+

“latitude:”+ event.latitude.toString() +“\n”


+

“longitude:”+ event.longitude.toString() +“\n”


+

“altitude:” +event.altitude.toString() +“\n”


+

“speed:” +event.speed.toString() +“\n”


+

“speed:” + mph.toString() + “MPH \n”


+

“speed:” +kph.toString() + “KPH \n”


+

“heading:” +event.heading.toString() +“\n”


+

“horizontal accuracy:”

+event.horizontalAccuracy.toString() +

“\n”


+

“vertical accuracy:”


+event.verticalAccuracy.toString();

}

]]>

</fx:Script>


<fx:Declarations>


<!– Place non-visual elements (e.g., services, value objects) here –>


</fx:Declarations>

<s:Label id=”status” text=”Geolocation” top=”10” width=”100%” textAlign=”center/>


<s:TextArea id=”info” width=”100%” top=”40” editable=”false/>


<fx:Declarations>


<!– Place non-visual elements (e.g., services, value objects) here –>


</fx:Declarations>


</s:Application>

 

  • Camera UI : Lets to explore Camera UI to take SnapShot from Real Device.

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009

xmlns:s=”

library://ns.adobe.com/flex/spark

applicationComplete=”application1_applicationCompleteHandler(event)”

>

<fx:Script>


<![CDATA[

import mx.events.FlexEvent;

privatevar camera:CameraUI;

protectedfunction application1_applicationCompleteHandler(event:Event) :void


{

if(CameraUI.isSupported) {

camera =

new CameraUI();

camera.addEventListener(MediaEvent.COMPLETE,onComplete);

camera.addEventListener(ErrorEvent.ERROR,onError);

status.text=

“CameraUI supported”;

}

else {

status.text=

“CameraUI not supported”;

}

}

privatefunction captureImage(event:MouseEvent):void {

camera.launch(MediaType.IMAGE);

}

privatefunction onError(event:ErrorEvent):void {

trace(“error hs occured”);

}

privatefunction onComplete(event:MediaEvent):void {

var mediaPromise:MediaPromise = event.data;

status.text =mediaPromise.file.url;

image.source = mediaPromise.file.url;

}

]]>

</fx:Script>


<fx:Declarations>


<!– Place non-visual elements (e.g., services, value objects) here –>


</fx:Declarations>


<s:Label id=”status” text=”Click Take a Picture Button” top=”10” width=”100%” textAlign=”center/>


<s:Button width=”300” height=”60” label=”TAKE a PICTURE” click=”captureImage(event)” horizontalCenter=”0” enabled=”{CameraUI.isSupported}

  top=”

80/>


<s:Image id=”image” width=”230” height=”350” horizontalCenter=”0” top=”170/>


<fx:Declarations>


<!– Place non-visual elements (e.g., services, value objects) here –>


</fx:Declarations>


</s:Application>

  • Camera Roll:
  • <?xml version=”1.0″ encoding=”utf-8″?>

    <s:Application

    xmlns:fx=”http://ns.adobe.com/mxml/2009

       xmlns:s=”

    library://ns.adobe.com/flex/spark

       applicationComplete=”application1_applicationCompleteHandler(event)”

    >


    <fx:Script>


    <![CDATA[

    import mx.events.FlexEvent;

    privatevar camera:CameraUI;

    protectedfunction application1_applicationCompleteHandler(event:FlexEvent):void{

    if(CameraUI.isSupported){

    camera =

    new CameraUI();

    camera.addEventListener(MediaEvent.COMPLETE,onComplete);

    camera.addEventListener(ErrorEvent.ERROR,onError);

    status.text=

    “CameraUI supported”;

    }

    else{

    status.text=

    “CameraUI NOT Supported”;

    }

    }

    privatefunction captureImage(event:MouseEvent):void {

    camera.launch(MediaType.IMAGE);

    }

    privatefunction onError(event:ErrorEvent):void {

    trace(“Error has occured”);

    }

    privatefunction onComplete(event:MediaEvent):void {

    var mediaPromise:MediaPromise = event.data;

    status.text = mediaPromise.file.url;

    image.source = mediaPromise.file.url;

    }

    ]]>

    </fx:Script>


    <fx:Declarations>


    <!– Place non-visual elements (e.g., services, value objects) here –>


    </fx:Declarations>


    <s:Label id=”status” text=”CLICK TAKE a Picture Button” top=”10

    width=”

    100%” textAlign=”center/>


    <s:Button width=”300” height=”60” label=”TAKE A PICTURE” click=”captureImage(event)”

      horizontalCenter=”

    0” enabled=”{CameraUI.isSupported}

      top=”

    80/>


    <s:Image id=”image” width=”230” height=”350” horizontalCenter=”0” top=”170/>

    </s:Application>

  • Camera Roll :

  • <?xml version=”1.0″ encoding=”utf-8″?>

    <s:Application

    xmlns:fx=”http://ns.adobe.com/mxml/2009

       xmlns:s=”

    library://ns.adobe.com/flex/spark

       applicationComplete=”application1_applicationCompleteHandler(event)”

    >


    <fx:Script>


    <![CDATA[

    import mx.events.FlexEvent;

    privatevar cameraRoll:CameraRoll

    protectedfunction application1_applicationCompleteHandler(event:FlexEvent):void {

    if(CameraRoll.supportsBrowseForImage) {

    cameraRoll =

    new CameraRoll();

    cameraRoll.addEventListener(MediaEvent.SELECT,mediaSelected);

    cameraRoll.addEventListener(ErrorEvent.ERROR,onError);

    }

    else {

    status.text =

    “CameraRoll NOT supported”;

    }

    }

    privatefunction browseGallery(event:MouseEvent):void {

    cameraRoll.browseForImage();

    }

    privatefunction onError(event:ErrorEvent):void {

    trace(“error has occured”);

    }

    privatefunction mediaSelected(event:MediaEvent):void {

    var mediaPromise:MediaPromise = event.data;

    status.text = mediaPromise.file.url;

    image.source = mediaPromise.file.url;

    }

    ]]>

    </fx:Script>


    <fx:Declarations>


    <!– Place non-visual elements (e.g., services, value objects) here –>


    </fx:Declarations>

    <s:Label id=”status” height=”60” text=”BROWSE GALLERY” top=”10” width=”100%” textAlign=”center/>

    <s:Button width=”300” height=”60” label=”BROWSE GALLERY

    click=”browseGallery(event)” enabled=”

    {CameraRoll.supportsBrowseForImage}

    top=”

    80” horizontalCenter=”0/>

    <s:Image id=”image” width=”230” height=”350” top=”170” horizontalCenter=”0/>


    </s:Application>

In Next Article, We will explore more APIs & Features of BlackBerry Tablet OS 7 with Adobe Flash Builder 4.5.

Advertisements

About Anindita
Anindita Basak is working as Big Data Cloud Consultant in Microsoft. Worked in multiple MNCs as Developer & Senior Developer on Microsoft Azure, Data Platform, IoT & BI , Data Visualization, Data warehousing & ETL & of course in Hadoop platform.She played both as FTE & v- employee in Azure platform teams of Microsoft.Passionate about .NET , Java, Python & Data Science. She is also an active Big Data & Cloud Trainer & would love share her experience in IT Training Industry. She is an author, forum contributor, blogger & technical reviewer of various books on Big Data Hadoop, HDInsight, IoT & Data Science, SQL Server PDW & PowerBI.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: