IT tutorials
 
Mobile
 

Developing BlackBerry Tablet Applications : File System Access (part 2) - File Browse for Single File

5/31/2013 7:55:04 PM
- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

3. File Browse for Single File

The browse for file functionality of the File class works a bit differently in BlackBerry Tablet OS as compared to the desktop version. Within BlackBerry Tablet OS, the browseForOpen method will open up a specific native file selector that will allow you to open a file of type Audio, Image, Documents, or Video. Since you are attempting to read these shared files, you will need to select the access_shared permission when creating your project. 

Let’s review the next code sample. The button with the “Browse” label will call the button1_clickHandler when clicked. Within this function, an instance of File is created with the variable name “file.” An event listener listening for the Event.SELECT event is added to the File object, then the browseForOpen method is called. The application is shown in Figure 4. When browseForOpen is called, the BlackBerry Tablet OS file selector is launched (see Figure 5). After selecting a file within the BlackBerry Tablet OS file selector, the event is fired and the onFileSelect method is called. The event.currentTarget is cast to a File object and its nativePath, extension, and url properties are used to display the nativePath and the image in the example shown in Figure 5-6.

<?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">

    <fx:Script>
        <![CDATA[

            protected function button1_clickHandler(event:MouseEvent):void
            {
                var file:File = new File();
                file.addEventListener(Event.SELECT, onFileSelect);
                file.browseForOpen("Open");
            }

            private function onFileSelect(event:Event):void {
                var file:File = File(event.currentTarget);
                filepath.text = file.nativePath;
                if(file.extension == "jpg"){
                    image.source = file.url;
                }
            }
        ]]>
    </fx:Script>

    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Button horizontalCenter="0" top="10" label="Browse" 
click="button1_clickHandler(event)"/>
    <s:Label id="filepath" left="10" right="10" top="100"/>
    <s:Image id="image" width="230" height="350" top="150" horizontalCenter="0"/>
</s:Application>

					  

Figure 4. Browse for file application


Figure 5. File selector


Figure 6. Browse for file with an Image selected


 
Others
 
- Developing BlackBerry Tablet Applications : File System Access (part 1)
- iPhone Developer : Assembling Views and Animations - Managing Subviews - Tagging and Retrieving Views
- iPhone Developer : Assembling Views and Animations - Recovering a View Hierarchy Tree, Querying Subviews
- Java ME on Symbian OS : Handling Diversity - Handling Screen and Display Diversity
- Java ME on Symbian OS : Handling Diversity - Handling Diverse Multimedia Formats and Protocols
- Java ME on Symbian OS : Handling Diversity - Supporting Diverse Input Mechanisms
- Windows Phone 7 : Building 2D Games with the XNA Framework - AlienShooter Game Play (part 6) - Updated GameplayScreen Class, Collision Detection and Memory Management
- Windows Phone 7 : Building 2D Games with the XNA Framework - AlienShooter Game Play (part 5) - Missile Class, Game Status Board Class
- Windows Phone 7 : Building 2D Games with the XNA Framework - AlienShooter Game Play (part 4) - Hero Ship Class
- Windows Phone 7 : Building 2D Games with the XNA Framework - AlienShooter Game Play (part 3) - Enemy Class
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
programming4us programming4us
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS