Share My Creation Flashlight app

francoisg

Active Member
Licensed User
Torch.png
Hi,
I created a very simple flashlight app using the advanced camera lib (uses camera led flash that a lot of android devices have).
It is freely available on the market (Hawkstone Flashlight) - it seems to be working for quite a few people ;-)

To use, start the app and the led lights up, click on the app icon again to unload and switch of led (works great as a shortcut on a launcher screen)

The nice thing about this is that it unloads itself from memory when not used (unlike some other flashlight apps that I have tried)

Tested on
- SE Experia X10 (Works)
- HTC Wildfire (Works)
- HTC Desire HD (Works)
- Dell Streak (Works)
- Motorola Defy / MB525 - (Does NOT work)

Nothing much but it proves the power of B4A :)
 

Attachments

Last edited:

francoisg

Active Member
Licensed User
Did you try the source code to see if you can find the problem (by the way, does the advanced camera lib flash light functionality actually work on the infuse 4g?)?
 

SlavaVB

Member
Licensed User
i tried to compile your app, but i get the following error code...

B4X:
Compiling code.                         Error
Error compiling program.
Error description: Unknown member: getcurrentflashmode
Occurred on line: 12
Dim FlashMode As String : Flashmode = cam.getCurrentFlashMode
Word: getcurrentflashmode
:sign0013:
 

SlavaVB

Member
Licensed User
i tried the following code, it compiles, however i get a java error message when i run the code on my Samsung Galaxy S2

B4X:
An error has occured in sub:
main_activity_create (B4A line: 16)
ac.FlashOn
java.lang.NullPointerException
Continue?
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim ac As AdvancedCamera
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   ac.FlashOn()
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

francoisg

Active Member
Licensed User
You need to use the latest version of the advanced camera lib (ACL, version 4.40) for the code to work ...
 

SlavaVB

Member
Licensed User
I tried the following code with ACL 4.40 but it still doesn't work


B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim cam As AdvancedCamera
End Sub

Sub Activity_Create(FirstTime As Boolean)
   cam.Initialize(Activity, "cam")
End Sub

Sub cam_Ready (Success As Boolean)
   cam.FlashOn
   Activity.Finish         

End Sub
 

Nick johnson

New Member
I like the feature of unloading itself from memory when not in use.....
By having this feature, user don't have to always remember to unload it from memory...
 

hackhack

Active Member
Licensed User
Well, the apk works on the padfone, the source doesn't compile into anything that works though. Would be cool to see the whole source.
 

Hubert Brandel

Active Member
Licensed User
B4X:
Error description: Unknown member: getcurrentflashmode
this is a missspelling (or old name), if you look into the cam object you find the right name:

B4X:
 cam.CurrentFlashMode
I found the AKP and the self compiled code working on a "Samsung Tab 7N",
but all tries to get it work inside my app ...
One Button just toggle on/off will not work (it says OK, but no light.)
If I use the cam:FlashOn I will see nothing, even when use cam:FlashTorch it goes on, but not off :sign0085:

Just see this:
toggleFlashLight
Attempts to set camera flash torch/flashlight mode on/off
HACK around
isOn: true = on, false = off
Return type: @return:boolean whether or not we were able to set it
If you have a Samsung, and you toggle the flash off, you will have to reinitialize your camera.
does this mean using cam:reconnect or even cam:Initialize (Panel, "cam")

android.view.ViewGroup: is this a B4A PANEL or IMAGEVIEW or a Activate or each one of those types ?
 

fared15

Member
Licensed User
correct

B4X:
Sub cam_Ready (Success As Boolean)
   Dim FlashMode As String 
   FlashMode = cam.CurrentFlashMode
   
   If FlashMode.ToUpperCase = "OFF" Then
      cam.FlashOn
      Activity.Finish         
   Else
      cam.FlashOff
      ExitApplication
   End If
End Sub
[\code]:sign0148:
Correct One coding
 

Dede33450

Member
Licensed User
Sorry very bad english,
but this code works on a Galaxy S3

_______________________

Sub Process_Globals

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim cam As AdvancedCamera
End Sub

Sub Activity_Create(FirstTime As Boolean)
cam.Initialize(Activity, "cam")
End Sub

Sub cam_Ready (Success As Boolean)
Dim FlashMode As String
FlashMode = cam.CurrentFlashMode
If FlashMode.ToUpperCase = "OFF" Then
cam.FlashTorch
Activity.Finish
Else
cam.FlashOff
ExitApplication
End If
End Sub
__________________________

(To use, start the app and the led lights up, click on the app icon again to unload and switch of led (works great as a shortcut on a launcher screen))
 

Attachments

Top