If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
jromanoski
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Invoke pictures application

[ Edited ]

Hello,

 

I've been searching through all the forums and still can't find an example on how to achieve this. Does anyone know how to invoke from my app the pictures explorer to let the user select either a picture from the gallery or take a photo from the camera? Like the foursquare app does when you select "upload a photo".

 

original.png

 

FYI, I am developing with version 5.0

 

Many thanks in advance.

Please use plain text.
Developer
Utel
Posts: 31
Registered: ‎04-13-2011
My Device: BlackBerry Torch 9800
My Carrier: Computer Enginneer

Re: Invoke pictures application

Hi,

Do you really search on all the community resources ?

Type "camera screen" for the camera features then "photo picker" for the picture picker....

Regards,
Please use plain text.
Developer
jromanoski
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Re: Invoke pictures application

Sorry, but I only found how to use file picker and the selection popup screen:

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800256/...

 

But I am not sure if this is what I am looking for. Before I go for those, are them a good approach for my purpose?

 

Thanks.

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: Invoke pictures application

Please use plain text.
Developer
jromanoski
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Re: Invoke pictures application

maadani,  

 

Many thanks for your help. Now with this code:

 

try {
					// Create an invocation instance with the specified URL
					// where the file type is one of the media types supported
					// by the media player.
					Invocation invocation = new Invocation(null, null,
							BlackBerryContentHandler.ID_MEDIA_CONTENT_HANDLER,
							false, ContentHandler.ACTION_OPEN);
					invocation
							.setArgs(new String[] { BlackBerryContentHandler.MEDIA_ARGUMENT_VIEW_PICTURES });

					// Get the Registry object using the class name of the
					// application
					Registry _registry = Registry.getRegistry(Application
							.getApplication().getClass().getName());

					// Invoke the content handler.
					_registry.invoke(invocation);
				} catch (IOException e) {
					System.out.println("Camera exception: " + e.getMessage());
				}

I am being able to invoke the media application to let the user choose among camera or pictures in the device. Now, after taking the photo or selecting a picture, how to select the image in my application? Is filejournallistener the best approach inthis case?

 

Thanks again for your help.

 

Regards 

Please use plain text.
Developer
alishaik786
Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified

Re: Invoke pictures application

[ Edited ]

I think File picker may help you: This below code works for select a photo from the SDCard or Device Memory;

 

public class Ghi extends MainScreen
{
	FilePicker filePicker;
	ButtonField select;
	byte data[];
	public Ghi() 
	{
		createGUI();
	}

	private void createGUI() 
	{
		
		select=new ButtonField("save");
		select.setChangeListener(new FieldChangeListener() 
		{
			public void fieldChanged(Field field, int context) 
			{
				callFilePicker();
			}
		});
		add(select);
		
		
	}
	
	private void callFilePicker()
	{
		synchronized (UiApplication.getUiApplication().getAppEventLock()) 
		{
			filePicker=FilePicker.getInstance();
			filePicker.setPath("file:///SDCard/BlackBerry/pictures/");//Your desired path. Before giving "setPath" check SDCRAD is present or not
			filePicker.setListener(new Listener() 
			{
				public void selectionDone(String selectedPath) 
				{
					try 
					{
						System.out.println("======================URL: "+selectedPath);
						FileConnection file = (FileConnection)Connector.open(selectedPath);
						
//						Do what ever you want. Means Take the picture in to Byte array and 
//						do something;
						
						file.close();					
					} 
					catch (Exception e) 
					{
						StartUp.exceptionHandling(e.getMessage());
					}
				}
			});
			filePicker.show();
		}
	}
}


//Here url nothing but the path up to your selected pictureName;
//if "sdcard" present then filePicker.setPath("file:///SDCard/BlackBerry/pictures/");
//else filePicker.setPath("file:///store/home/user/pictures/");

 

This works for selecting the pictures and do something;

===========================================================================

 

Feel free to click like button

 

=================================================================================
Feel free to click LIKE button if the solution helps you;
--
Regards,

ALI SHAIK.
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Invoke pictures application

You might find this Thread useful for selecting the Camera image last taken.

http://supportforums.blackberry.com/t5/Java-Development/How-to-catch-last-photo/td-p/1492439

Please use plain text.
Developer
jromanoski
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Re: Invoke pictures application

@alishaik786

 

The code you posted only works for selecting an image from the library. I want to let the user either select the image from the library or take the photo...

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Invoke pictures application

To do that I think you are going to have to use a combination of what I can you and what alishaik786 gave you.  Not sure though, never done it.

Please use plain text.
Developer
jromanoski
Posts: 90
Registered: ‎09-07-2010
My Device: Not Specified

Re: Invoke pictures application

Thanks Peter. Yes I was thinking the same, though seems strange because I've seen lots of apps doing the same thing (Foursquare, Facebook, Tuenti...) and it seems pretty easy to implement.

 

I'll keep this thread updated in case i have some good news...

Please use plain text.