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: 55
Registered: ‎05-30-2011
My Device: BlackBerry torch 9800
My Carrier: Airtel
Accepted Solution

Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

[ Edited ]

Hello All,

 

I am developing an application which make use of camera...and my app's requirement is :

 

I have to take pictures from my "already running" background application ; but I have to keep camera application into background......means I want to capture picture without disturbing the foreground applications.

 

and in addition without making any camera shutter sound....???

 

Is this possible If we call camera app - through Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA,  new CameraArguments())...........

 

Plese help...... and give me links if there any  related to this prob...

 

thanks.

 

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

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

Look at the Camerademo sample that comes packaged.  Let us know if this does not answer your questions.

Developer
Posts: 55
Registered: ‎05-30-2011
My Device: BlackBerry torch 9800
My Carrier: Airtel

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

Smiley Happy Sure.... Peter !!!  Soon I'll come back to this post...

 

Rajani.

Developer
Posts: 55
Registered: ‎05-30-2011
My Device: BlackBerry torch 9800
My Carrier: Airtel

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

HI peter......sorry to come back on this post very late.

 

as I hv already mentioned that I want to capture snap from background....means without bringing the camera screen into forground...

 

but after some attempts I hv found that  without bringing the camera screen into foreground we cant capture the snap.

1) If we put the camera screen into background OR

2) change the visibility of VideoControl's class object as false... by...

_videoControl.setVisible(false);

 

then no bytes (null value) will be received by...

byte[] imageBytes = _videoControl.getSnapshot( encoding );	 

So Peter whats the use of this function....while we r using the video control class for capture snap or video???

_videoControl.setVisible(true);

 

and I also want to confirm on this...?? till yet I am not sure about.......is there any other way to take snap without bringing the camera screen into foreground.....????

 

I hv tried a different trick......

- I call a thread just before bring the camera screen into foreground to off the back-light of the device.

- then soon after that I bring the camera screen into foreground and capture the snap.

I hv tested the above trick on BB Flip (4.6) and Storm (5.0) devices and it takes snapshots successfully even when device back light is OFF.

 

But now I become stuck on some other problem....and that is the camera SHUTTER sound. I hv tried a lot but couldn't get success to mute it....

I hv tried

private void muteThread() {
		Thread t = new Thread(new Runnable() {
			public void run() {
				try {
					int i = 0;
					while (i < 50) {
						Audio.setVolume(0);
						try {
							Thread.sleep(50);
						} catch (InterruptedException e) {						
						}
						i++;
					}
					System.out.println("\n\n >>>>> End of Mute Thread. <<<< \n\n");
				} catch (Exception e) {
				}
			}
		});
		t.start();
	}

 

but it is not working... If this cant be done then how these application r providing this facility...and wht kind of functionality they hv used.

http://appworld.blackberry.com/webstore/content/97648/?lang=en

http://appworld.blackberry.com/webstore/content/79083/?lang=en

I am very anxious about this...pls give some idea, if u hv..

 

Thanks,

Rajani


 

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

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

I was not aware of this:

 

"we cant capture the snap ..... If we put the camera screen into background"

 

I thought that would work. 

 

I am sorry to say I don't know the answer to your question.  Hopefully someone else can help?

Developer
Posts: 55
Registered: ‎05-30-2011
My Device: BlackBerry torch 9800
My Carrier: Airtel

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

[ Edited ]

Hi Peter ,

 

I hv comleted my task in  following way ; hpoe this will help other users : 

 

as I mentioned in my previous post :


I hv tried a different trick......

- I call a thread just before bring the camera screen into foreground to off the back-light of the device.

- then soon after I bring the camera screen into foreground and capture the snap.

I hv tested the above trick on BB Flip (4.6) and Storm (5.0) devices and it takes snapshots successfully even when device back light is OFF.


I hv tested the above trick on all devices from BB version 4.6.0 to 7.0  and it works fine. So now I can concluded that we can capture the snapshot when device - backlight is off (but can't record the video programmatically).

 

 

and for camera shutter sound.....I hv controlled it in following way :

 

1) store  the device current volume level in a variable by -

 

audioVol = Audio.getVolume();

 2) run the mute thread -

 

private void muteThread() {
		Thread t = new Thread(new Runnable() {
			public void run() {
				try {
					int i = 0;
					while (i < 50) {
						Audio.setVolume(0);
						try {
							Thread.sleep(50);
						} catch (InterruptedException e) {						
						}
						i++;
					}
					System.out.println("\n\n >>>>> End of Mute Thread. <<<< \n\n");
				} catch (Exception e) {
				}
			}
		});
		t.start();
	}

 3) run the camera - snap shot thread.

 

4) and at  the end, run the unmute thread -

public static void unMuteThread(final int vol) {
		Thread t1 = new Thread(new Runnable() {
			public void run() {
				try {
					int vol2 = vol;
					int i = 0;
					if(vol2 == 0) {  //// vol2 < audioVol || 
						vol2 = audioVol;
					}
					
					while (i < 50) {
						Audio.setVolume(vol2);
						try {
							Thread.sleep(50);
						} catch (InterruptedException e) {						
						}
						i++;
					}
					System.out.println("\n\n >>>>> End of UnMute Thread. <<<< \n\n");
				} catch (Exception e) {
				}
			}
		});
		t1.start();
	}

 

my program is successfully taking snap shots without making any camera shutter sound. Smiley Very Happy

 

thanks for ur cooperation,

Rajani

 

 

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

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

Well done.

 

And thanks very much for documenting your findings for the next person. 

Developer
Posts: 112
Registered: ‎04-28-2010
My Device: 8520
My Carrier: AirTel

Re: Is this possible to take photos programmatically without bringing the default camera application into foreground in blackberry…?

hi rajani,

 

thanks for sharing.

I am also working on similar type of functionality.

I have also tried to take picture when backlight is off. But i always gets null value. It is working fine when back light is enable.

 

Plz share some code of that functionality.

 

Thanks & Regards,

Dinesh