Lock all folders and apps from opening in Blackberry

Here i am describing how to lock your home screen. Here ‘lock’ means, when i am pressing any folder or app icon, it should not open or start.

import java.util.Timer;
import java.util.TimerTask;

import net.rim.device.api.applicationcontrol.ApplicationPermissions;
import net.rim.device.api.applicationcontrol.ApplicationPermissionsManager;
import net.rim.device.api.system.Application;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.Characters;
import net.rim.device.api.system.EventInjector.KeyEvent;

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();
     * This method showcases the ability to check the current permissions for
     * the application. If the permissions are insufficient, the user will be
     * prompted to increase the level of permissions. You may want to restrict
     * permissions for the ApplicationPermissionsDemo.cod module beforehand in
     * order to demonstrate this sample effectively. This can be done in
     * Options/Advanced Options/Applications/(menu)Modules.Highlight
     * 'ApplicationPermissionsDemo' in the Modules list and select 'Edit
     * Permissions' from the menu.
    private void checkPermissions()
		// Capture the current state of permissions and check against the requirements
        ApplicationPermissionsManager apm = ApplicationPermissionsManager.getInstance();
        ApplicationPermissions original = apm.getApplicationPermissions();
		if(original.getPermission(ApplicationPermissions.PERMISSION_INPUT_SIMULATION) == ApplicationPermissions.VALUE_ALLOW)
            // The necessary permissions are currently available
// Create a permission request for each of the permissions your application
        // needs. Note that you do not want to list all of the possible permission
        // values since that provides little value for the application or the user.  
        // Please only request the permissions needed for your application.
        ApplicationPermissions permRequest = new ApplicationPermissions();
        boolean acceptance = ApplicationPermissionsManager.getInstance().invokePermissionsRequest(permRequest);

            // User has accepted all of the permissions
            // The user has only accepted some or none of the permissions 
            // requested. In this sample, we will not perform any additional 
            // actions based on this information. However, there are several 
            // scenarios where this information could be used. For example,
            // if the user denied networking capabilities then the application 
            // could disable that functionality if it was not core to the 
            // operation of the application.
	TimerTask mCheckForeground = new TimerTask() {
	    public void run() {
	        int id = getForegroundProcessID();
			ApplicationManager appMan = ApplicationManager.getApplicationManager();
			KeyEvent inject = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
	private int getForegroundProcessID() 
	    return ApplicationManager.getApplicationManager().getForegroundProcessId();

This is required generally for some application. If you don’t want to give the privilege to open any app or folder while he is driving. May be it is obstructing the basic behavior of Blackberry.


2 thoughts on “Lock all folders and apps from opening in Blackberry

  1. This block is very useful to block application on programeticaly. if i need to block some particular app. like i need to block only camera or wifi than how it possible? Not all application

    1. If you want to block some particular application, i think you have to check whether it is running in foreground or not. And using Codemodule manager you can get the module name and id. Then try to block it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s