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
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900

Problem in FilePicker

Hi

In my application, i have to change the image and choose the image from the folder or capture from the camera. 

So i have used the fiel picker code in my application.The code is working well but today i found an unexcepted error.

 

The image is not changing.

 

public MyApp()

{

ButmapField image = new BitmapField(image1);

add(image);

 

// i have added the listener to the field.When the image gets focused, filepicker gets open.

Here is the code..

 

 

 

try
{
FilePicker filePicker;
filePicker=FilePicker.getInstance();
filePicker.setPath("file:///SDCard/BlackBerry/pictures/");
filePicker.setListener(new Listener()
{
public void selectionDone(String path)
{
path1=path;
Profileimage =getTheImage(path1);
Bitmap newImage1=ArealAppScreen.resizeImage(Profileimage, profileX, profileY);

image.setBitmap(newImage1);

}
});
filePicker.show();//it show what ever you select.

}
catch (Exception e)
{
System.out.println("exception : "+e.getMessage()+e.toString()+e.getClass());
e.printStackTrace();

}

}

Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900

Re: Problem in FilePicker

Can anyone tell me why i am not getting the image???

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Problem in FilePicker

is it working sometimes, or not at all?

i wonder if the image-field is available in the callback of the filepicker, mit it not being defined as a class variable.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900

Re: Problem in FilePicker

Thanks Sir for the reply.

I have declared the variable as global.The code was working fine few months back. I didn't change anything but suddendly it stopped working.

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in FilePicker

[ Edited ]

Is this on a Simulator or real device?  All devices or just some?  Which devices and which OS's are involved. 

 

When you step through the selectionDone() code what happens? 

Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900

Re: Problem in FilePicker

I am running this on device.

Blackberry Bold,OS 7.0

 

After selection done, it pauses for 5-6 seconds then the originalimage displays . 

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in FilePicker

Can you answer all the questons - you missed

"When you step through the selectionDone() code what happens? "

 

If you can't debug on device, then put some logging in (or System.out...) and check each step.

Developer
robert30
Posts: 191
Registered: ‎04-02-2013
My Device: BlackBerry Bold 9900

Re: Problem in FilePicker

Sir

 

I have printout the following statements in my app.After printing BMP image is ...it pause for4-5 seconds then the original image displays on the screen

 

public void selectionDone(String path)
{
path1=path;
System.out.println("Name of the path is : "+path1);
image1 =getTheImage(path1);
System.out.println("image : "+image1+" x is : "+profileX+" y i s:"+profileY);
Bitmap newImage1=ArealAppScreen.resizeImage(image1, profileX, profileY);

System.out.println("Bytes of the image : "+path1.getBytes());
System.out.println("BMP image is... "+Profileimage.getType());
profileField.setBitmap(newImage1);

}

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in FilePicker

[ Edited ]

And do you see these lines of output when testing?

 

And can you add an additional logging line after the setBitmap?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Problem in FilePicker

path1.getBytes() does not give you the bytes of the image. just saying.
i also don't see what profileX is and how it is relevant, is it a variable set by getTheImage?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter