08-04-2010 06:05 AM
Hi,
as I know the key event are associate with the screen and you get the that event on that screen only so may be you will not get he key event in your application running in background.
Regards
Tita
08-04-2010 06:41 AM
Hi Amrinder,
You can push global screen like from ur backgrouond app, in this way :
synchronized(Application.getEventLock() ){
Application.getApplication().invokeLater( new Runnable() {
public void run() {
UiEngine ui = Ui.getUiEngine();
ui.pushGlobalScreen( screen, 1, UiEngine.GLOBAL_MODAL);
}
});
}
Now u have to create a transparent screen by extending any Screen and use
createSolidTransparentBackground(int color,int alpha) from Class.net.rim.device.api.ui.decor.BackgroundFactory
Thanks
Kanak
08-04-2010 08:13 AM
While a transparent screen will indeed mean that the screen will capture the UI interaction, the followup question is how do you then translate that to movements on the underlying Home Screen. You could use Event Injection, but then of course the transparent screen will capture these, So you have to pop the transparent screen, perform the Event Injection and push the transparent screen again. And then of course how do you handle it when the user actually does a real UI interaction, such as moving the trackball themselves?
I think the OP described the requirement as:
"My main aim for this application is that with the help of keys ,I use the function of trackball for moving right ,left ,up and down on blackberry device or on whole bb phone"
In my opinion, this requirement overall can not be achieved using the currently published API.
I suspect there is more to this however. I would like the OP to explain why the user can not just use the trackball to move the icon focus? How does using the keyboard improve the user's experience?
I suspect the OP's real requirement is to start another application and I think there are other ways of achieving this. I think this approach is likely to waste a lot of time and not be particularly satisfactory.
But that is just my opinion!
08-05-2010 03:36 AM
hi peter sir and kanak maam
Now ,trying to implement the app running background .
and then i will try to create the transparent screen .
i will let you know ,what happened next .
thanks for supporting me .
regards
Amrinder singh
08-07-2010 02:25 AM - edited 08-07-2010 02:34 AM
package startUpConfigure; import net.rim.device.api.system.Characters; import net.rim.device.api.ui.Keypad; import net.rim.device.api.ui.component.RichTextField; import net.rim.device.api.ui.container.MainScreen; public class Keys extends MainScreen { RichTextField rich; public Keys() { rich = new RichTextField("Hello ,how r u ?,kiddan ho gsdgfjgdjgdgjhj" + "jkbjbfrgvfbjkfnbngfb gfngnfjkberhgrio"); add(rich); } protected boolean keyControl(char c, int status, int time) { switch (c) { case Characters.CONTROL_VOLUME_DOWN: rich.setText(rich.getText()+" CONTROL_VOLUME_DOWN "); this.navigationMovement(0, 1, status, time); return true; case Characters.CONTROL_VOLUME_UP: rich.setText(rich.getText()+" CONTROL_VOLUME_UP "); this.trackwheelRoll(1, status, time); return true; } return super.keyControl(c, status, time); } public boolean keyDown(int keycode,int time) { if (Keypad.KEY_CONVENIENCE_1 == Keypad.key(keycode)) { this.navigationMovement(1,0,0,time); return true; } if (Keypad.KEY_CONVENIENCE_2 == Keypad.key(keycode)) { this.navigationMovement(-1,0,0,time); return true; } return false; } }
Above is the code of moving the focus left,right,up,down with the help of keys .
i tried to get the below code in my code that would help me in running the background
synchronized(Application.getEventLock() ){
Application.getApplication().invokeLater( new Runnable() {
public void run() {
UiEngine ui = Ui.getUiEngine();
ui.pushGlobalScreen( screen, 1, UiEngine.GLOBAL_MODAL);
}
});
}
but cant able to run the app background ,i had tried every logic for using this code
plese help me in integrated this code with my code .
please help in creating the createSolidTransparentBackground(int color,int alpha) from Class.net.rim.device.api.ui.decor.BackgroundFactor
regards
Amrinder singh
08-07-2010 02:48 AM
Is your application a background application? U can make an application to background, by extending Application in your main class. Right Click on Project Properties -> Application Tab -> check System Module & Auto run on start-up.
Now, to make a transparent Screen extend Any Screen class like FullScreen. And in its constructor call
setBackground(Field.VISUAL_STATE_NORMAL, BackgroundFactory.createSolidTransparentBackground
Now, implement Keylistener interface to listenf for Key events.
Kanak
08-07-2010 05:12 AM
Let me be direct here amrinder_singh.
Once you have your transparent screen, you will not be able to use navigation movement to move the focus around the icons in the home screen. Let me repeat, you will not be able to control the Homescreen in this way.
Can you please, before you ask for any more technical assistance, describe what you are trying to do - from a user perspective.
And please don't just say, "I am trying to move the cursor round on the Home Screen". We want to know why you are trying to move it. And how does this help the BlackBerry user? What can your application do using this facility that it can not' do any other way?
I think you are wasting a lot of your time and other people's time trying to do something that can't be done, at least not in the way you seem to think you want to do it. So please tell us what you are trying to achieve so that we can advise you of the best way.
08-07-2010 06:08 AM
import net.rim.device.api.ui.UiApplication;
public class sTARTUP extends UiApplication
{
private static sTARTUP _theApp;
private Keys _Keys;
public sTARTUP()
{
_Keys = new Keys();
UiApplication.getUiApplication().pushGlobalScreen( _Keys, 0, 0);
}
public static void main(String args[])
{
_theApp = new sTARTUP();
if (_theApp != null)
{
_theApp.enterEventDispatcher();
}
}
import net.rim.device.api.system.Characters;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Keypad;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.decor.BackgroundFactory;
public class Keys extends MainScreen
{
private RichTextField rich;
public Keys()
{
setBackground(Field.VISUAL_STATE_NORMAL, BackgroundFactory.createSolidTransparentBackground (Color.BLACK, 2));
}
protected boolean keyControl(char c, int status, int time)
{
switch (c)
{
case Characters.CONTROL_VOLUME_DOWN:
rich.setText(rich.getText()+" CONTROL_VOLUME_DOWN ");
this.navigationMovement(0, 1, status, time);
return true;
case Characters.CONTROL_VOLUME_UP:
rich.setText(rich.getText()+" CONTROL_VOLUME_UP ");
this.trackwheelRoll(1, status, time);
return true;
}
return super.keyControl(c, status, time);
}
public boolean keyDown(int keycode,int time)
{
if (Keypad.KEY_CONVENIENCE_1 == Keypad.key(keycode))
{
this.navigationMovement(1,0,0,time);
return true;
}
if (Keypad.KEY_CONVENIENCE_2 == Keypad.key(keycode))
{
this.navigationMovement(-1,0,0,time);
return true;
}
return false;
}
}
i had done according to the above code and i had check the system module and auto startup .
When i run the above classes ,then in the blackberry simulator a at the atrting time ,i had get the screen of white background ,to which i cant able to do any key command .
please suggest me ,what i do for this problem ?
regards
Amrinder singh
08-07-2010 06:19 AM
hi peter sir
From the user point of view ,my application help the user in that way ,when the trackball stop working due to some reason ,then the user start using the keys for moving it to various directions .
As my blackberry device 's trackball stop working properly ,if got this application installed ,then no new trackball i had to buy ,with the help of keys i start moving the focus left ,right,up and down .
that is the main point regarding this project .
This is the project that i had assigned to complete this before time .
As such trackball cost much and trackball working not properly is common in many handsets of bb .
that is regarding the project .
Thank you very much sir for taking initiative for my problem .
regards
Amrinder singh
08-08-2010 05:10 AM
"when the trackball stop working due to some reason ,then the user start using the keys for moving it to various directions"
This I understand. I have had this happen to devices I own.
A few thoughts.
As well as the Home Screen, if an application screen is on top, being able to use the trackball is essential then too. So you really want this processing for all screens. Just the Home Screen is not enough to be useful. This needs to be available for things like email.
Whatever screen is on the top of the stack will soak up most of the keys that are pressed. So putting a transparent screen on top will not work because then it will receive all key strokes. The only way it can pass these on is to use Event Injector, so then the transparent screen will have to be popped, then Event Injector used to pass on the key stroke, the the transparent screen put back up to accept the next input. This is never going to work in a way that is satisfactory. So I think you can give up on the transparent screen idea.
So you are left with having a background key Listener. Try it. it receives some of the keys regardless of which application is on top (note that you need to try this on device too because I have noted differences in the way Simulators and devices work with this). You will need to find at least 3 keys in order to be able to simulator left, right, up and down. Whatever keys you pick will therefore not be available to the device fro anything else. Whatever keys you find will not be be available for anything else since you will take them to simulate trackball movements.
Note that 3 keys will only work if you can detect when two keys are being held down together. If not, you will need 4!
Given that you can find three keys that you can use, then you need to start a background keylistener, and using EventInjector to inject the trackball movement. I'm not sure how to do this, look at the API and search the forum and KB for information. I remember seeing a KB article about it at some time, so I think if you look hard enough, you will find something.
In summary, if they user installs you application, then they might be able to 'disable' 3/4 keys (like the convenience keys) and use these to move the focus around. It is your call as to whether you think your users will accept this or not. In my part of the world, I suspect most users would not.