在黑莓的单个应用程序中禁用声音

发布于 2025-01-05 02:46:39 字数 79 浏览 1 评论 0原文

我刚刚在黑莓上做了一个字典应用程序以及语音到文本转换支持。一切都工作正常。现在我想在用户需要时禁用声音那么我该如何以编程方式做到这一点。请帮助我

I just did a dictionary application in blackberry along with a speech to text conversion support .Everything is working fine. Now i wanted to disable the sound when the user needs So how can i do it programmatically .Please help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2025-01-12 02:46:39

尝试这个

use the flag value as reference


if flag value is true then user click on item then it will play the sound
else sound wont play and display one dialog that Do you want enable sound with two options yes or no 
            if user click on yes then make flag value as true and item.setText("Voice Disable"); otherwise no action means no changes in flag
             in your list item click listener write condition as following
            if(flag==true)
            {
                write your logic to play
            }

示例代码是

public class app extends UiApplication{


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

    public app() {
        pushScreen(new SampleScreen()); 
    }
}
class SampleScreen extends MainScreen
{
    static boolean flag=true;
    MenuItem item=null;
    public SampleScreen() {

//      use the flag value as reference
//      if flag value is true then user click on item then it will play the sound
//      else sound wont play and display one dialog that Do you want enable sound with two options yes or no 
//      if user click on yes then make flag value as true and item.setText("Voice Disable"); otherwise no action means no changes in flag
//       in your list item click listner write condition as following
//      if(flag==true)
//      {
//          write your logic to play
//      }



        // you already implement 

        item=new MenuItem("Voice Disable",0,100) {
            public void run() {
                if(flag)
                {
                    flag=false;
                    item.setText("Voice Enable");
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            Dialog.inform("Voice Disable succesfully");
                        }
                    });
                }else{
                    flag=true;
                    item.setText("Voice Disable");
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            Dialog.inform("Voice Enable succesfully");
                        }
                    });
                }

            }
        };
        addMenuItem(item);

    }
}

Try this

use the flag value as reference


if flag value is true then user click on item then it will play the sound
else sound wont play and display one dialog that Do you want enable sound with two options yes or no 
            if user click on yes then make flag value as true and item.setText("Voice Disable"); otherwise no action means no changes in flag
             in your list item click listener write condition as following
            if(flag==true)
            {
                write your logic to play
            }

sample code is

public class app extends UiApplication{


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

    public app() {
        pushScreen(new SampleScreen()); 
    }
}
class SampleScreen extends MainScreen
{
    static boolean flag=true;
    MenuItem item=null;
    public SampleScreen() {

//      use the flag value as reference
//      if flag value is true then user click on item then it will play the sound
//      else sound wont play and display one dialog that Do you want enable sound with two options yes or no 
//      if user click on yes then make flag value as true and item.setText("Voice Disable"); otherwise no action means no changes in flag
//       in your list item click listner write condition as following
//      if(flag==true)
//      {
//          write your logic to play
//      }



        // you already implement 

        item=new MenuItem("Voice Disable",0,100) {
            public void run() {
                if(flag)
                {
                    flag=false;
                    item.setText("Voice Enable");
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            Dialog.inform("Voice Disable succesfully");
                        }
                    });
                }else{
                    flag=true;
                    item.setText("Voice Disable");
                    UiApplication.getUiApplication().invokeLater(new Runnable() {
                        public void run() {
                            Dialog.inform("Voice Enable succesfully");
                        }
                    });
                }

            }
        };
        addMenuItem(item);

    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文