如何在J2ME中使用“lockSystem”方法锁定Blackberry应用程序中的键盘?

时间:2010-04-09 09:48:39

标签: blackberry java-me

如何在J2ME中使用“lockSystem”方法锁定Blackberry应用程序中的键盘? 并且黑莓的亮度应该降低到零?

1 个答案:

答案 0 :(得分:1)

真的很容易。我知道答案。我们可以使用“lockSystem”方法。我编码如下锁定键盘。我需要很长时间才能找到它,但是你得到了它。

package net.asem;
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;


public class LockBlackberry extends UiApplication
{
    public static void main(String[] args) 
    {
        LockBlackberry lockB = new LockBlackberry();
        lockB.enterEventDispatcher();
    }
    LockBlackberry()
    {
        pushScreen(new myBlackBerryClass());

    }
}
final class myBlackBerryClass extends MainScreen implements FieldChangeListener<br>
{
    LabelField title;
    ButtonField btn1;
    myBlackBerryClass()
    {
        LabelField title = new LabelField("Title : Locking the Device.",LabelField.USE_ALL_WIDTH | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        btn1 = new ButtonField("KeyPad Loack ?",ButtonField.CONSUME_CLICK);
        btn1.setChangeListener(this);
        add(btn1);
    }
    public void fieldChanged(Field field, int context)
    {
        if(field == btn1)
        {
         Click();
        }

    }
    private void Click()
    {
        ApplicationManager manager = ApplicationManager.getApplicationManager();
        manager.lockSystem(true);
    }

}