Arindam Mukherjee
Arindam Mukherjee

Reputation: 2285

Application is not working in Device but working in simulator in Blackberry

I have one application by using which i will block the foreground application. It means when i am clicking any icon in the home screen it should not start. And my application is running in the background and will start when phone will start booting up. So i checked the Auto-run on start up. This is working fine in the simulator but not working in the device after running the cod file. I am running in Blackberry Storm. Here i am putting my code:

public class BlockApplication extends Application 
{
    int mForegroundProcessId = -1;

public BlockApplication() {
    Timer timer = new Timer();
    timer.schedule(mCheckForeground, 1000, 1);                       
}


public static void main(String[] args) {
    BlockApplication app = new BlockApplication();
    app.enterEventDispatcher();
}


TimerTask mCheckForeground = new TimerTask() {
    public void run() {
        int id = getForegroungProcessID();
        ApplicationManager appMan = ApplicationManager.getApplicationManager();
    appMan.requestForegroundForConsole();
        KeyEvent inject = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
       inject.post();

    };
};


private int getForegroungProcessID() 
{
    return ApplicationManager.getApplicationManager().getForegroundProcessId();
}

}

Can any one help? What is the problem?

Upvotes: 0

Views: 649

Answers (1)

Vit Khudenko
Vit Khudenko

Reputation: 28418

Just an idea - have you setup permissions for your app?

For instance, your app uses KeyEvent injection - something that is potentially dangerous and thus requires an explicit permission from user. In device Options (on my Storm 9530 simulator it is in the 'Options' -> 'Security Options' -> 'Application Permissions' -> select your app -> 'Edit Permissions' menu item) the permissoin for KeyEvent injection is named as "Input Simulation". It is also possible to set up permissions for the app using programmatic way (check ApplicationPermissionsManager class for this, also you can review ApplicationPermissionsDemo project that is included with the JDE).

Note that it is impossible to simulate permission framework on simulator (simulator acts as if all permissions are always set to "Allow"), so to test permissions you need real device.

Upvotes: 1

Related Questions