Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 81
Registered: ‎12-04-2012
My Device: BlackBerry@8520 smartphone(Edge,Wi-fi)
My Carrier: vodafone
Accepted Solution

cud sumone fix this code

package mypackage;

import net.rim.device.api.ui.UiApplication;

import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.picker.FilePicker;

class FilePickerScreen extends MainScreen
{
    public FilePickerScreen()
    {
        setTitle("File Picker Demo");
        add(new LabelField("Trying file picker"));
        
        UiApplication.getUiApplication().invokeLater(new Runnable( public void run()
                                                                   {FilePicker fp = FilePicker.getInstance();
                                                                    FilePickListener fileListener = new FilePickListener();
                                                                    fp.setListener(fileListener); 
                                                                    fp.show();  
 });
        
       
    
    }    
    

	
}

 

Highlighted
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: cud sumone fix this code

What is wrong with it?

 

There was an issue with FilePicker on some levels of OS 6.0 from memory, search the forum for more. 

Developer
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10
My Carrier: Orange

Re: cud sumone fix this code

[ Edited ]

use menu or button to open filepicker. you can't code in the constructor itself.

 

void addApplicationMenu(MainScreen mainScreen) {
        MenuItem appendUnreadMenuItem = new MenuItem("Open File", 1, 1) {
            public void run() {
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run() {
                        FilePicker fp = FilePicker.getInstance();
                        FilePickListener fileListener = new FilePickListener();
                        fp.setListener(fileListener);
                        fp.show();  
                    }
                });
            }
        };
        mainScreen.addMenuItem(appendUnreadMenuItem);
    }

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.