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

Posts: 140
Registered: ‎02-08-2010
My Device: Torch 9800, Storm 9530, Curve 8330
My Carrier: AT&T, Verizon

Source for MicroFire video-light flashlight

Most of the video-light flashlights in distribution have progressed way beyond the basic function, so it seems harmless to publish the source code for the basic function. This shouldn't take anyone long to figure out anyway, it's obvious, but for those who are learning how to code and are curious, here's something to play with:



    MicroFire PS (Published Source) 0.9
    Copyright (c) 2010 by LSphone
    All Rights Reserved (except as noted)
    Original or derivative(s) may be redistributed as source
(but not distributed built for use), as long as this
copyright notice and statement are included, unaltered. This is MicroFire stripped to its core and published as
unbuilt source code. The cover screen and meter are
removed, but the backlight still dims to reduce glare
and extend battery life. Built with JDE 4.2.1, it's
compatible with all BlackBerries with video cameras, and
under 2.5K without an icon. Symbols are short to reduce size. The app starts the
video camera just like clicking the video camera icon,
then keeps enabling the backlight. That keeps resetting
the idle timer, so nothing times out and the camera light
stays on. */ package lsphone.flash.microfireps; //import java.lang.*; import java.util.*; import net.rim.device.api.ui.*; import net.rim.device.api.system.*; import net.rim.blackberry.api.invoke.*; class C extends UiApplication { public static C A; public static ApplicationManager G; public static ApplicationDescriptor vad; public Timer T; public TT tt; public static int P; public int L; public static void main(String[] args) { G = ApplicationManager.getApplicationManager(); try { int M = CodeModuleManager.getModuleHandle("net_rim_bb_videorecorder"); vad = (CodeModuleManager.getApplicationDescriptors(M))[0]; } catch (Exception e) { return; } if (A == null) { A = new C(); A.enterEventDispatcher(); } else A.requestForeground(); } public C() { L = Backlight.getBrightness(); Backlight.setBrightness(10); } public void activate() { G.requestForegroundForConsole(); if (tt == null) (T=new Timer()).schedule(tt=new TT(), 0, 250); else tt.rs(); } public void sd() { T.cancel(); T = null; tt.cancel(); tt = null; Backlight.setBrightness(L); A = null; G.requestForegroundForConsole(); System.exit(0); } } class TT extends TimerTask { public int FR=28; public volatile int fr; public volatile boolean i; public TT() { rs(); } public void rs() { fr = 0; i = false; } public void run() { boolean T=false; if (--fr <= 0) { Backlight.enable(true); fr = FR; } if (C.G.getForegroundProcessId() == C.P) { i = true; } else { if (i || ((fr==0) && !i)) T=true; else { if ((fr >= 12) && ((fr % 4) == 0)) { try { C.A.P = C.G.runApplication(C.vad, true); } catch (ApplicationManagerException e) { T = true; } } } } if (T) synchronized(C.A.getEventLock()) { C.A.sd(); } } }


Most of what looks like unnecessary complexity is just to get it to quit when it's supposed to.  Smiley Happy





New Developer
Posts: 31
Registered: ‎07-06-2009
My Device: Not Specified

Re: Source for MicroFire video-light flashlight

you are a legend. Except there is one problem. How do i get it to turn the light on if its not on?


I got this bit to work, and was pretty obvious really, but i cant get it to automatically turn the light on. Any ideas?

Posts: 140
Registered: ‎02-08-2010
My Device: Torch 9800, Storm 9530, Curve 8330
My Carrier: AT&T, Verizon

Re: Source for MicroFire video-light flashlight

There are at least 2 ways of turning the light on.  LSphone uses one method, and JaredCo uses the other method, and I don't think that anyone else even bothers doing it.


Since there is a lot of competition going on in the "flashlight market", right now I can't explain how to do it.  It took a while to get my method right, and I'm sure it took JaredCo a while to get their method right.


Also, only a few of us have cover screens, and that was tricky to get right too.  I didn't mind sharing the basics, but don't want to make it too easy for serious competition to crop up.


The video camera was never meant to be used this way, and if you try to make a full flashlight with cover screen and auto-turn-on, you'll find there are many glitches to solve.


Unless you're smart or lucky, in which case... I'll be watching to learn from whatever you come up with.

Posts: 140
Registered: ‎02-08-2010
My Device: Torch 9800, Storm 9530, Curve 8330
My Carrier: AT&T, Verizon

Re: Source for MicroFire video-light flashlight

Ah, P.S. ...


since MicroFire is no longer available in stores, here is the runnable app (with the cover screen and meter).  I don't think many customers will be browsing this thread, so this shouldn't have much if any impact on sales of Video Flashlight or its cousins.


Version -42 is for OS 4.2-4.6, and version -47 is for OS 4.7+.


There's no difference whatsoever in the code for the two versions; you just build the 4.7+ version on the 4.7 JDE so that it will work properly on the Storm.  Otherwise, it will come up in "compatibility mode".


The zip's have alx's for desktop install, and jad's for on-phone install (copy the jad and cod to your media card), or you can use "javaloader -u load MicroFire.cod" for a USB install.