如何从具有单实例启动模式的活动正确启动语音识别活动?
已经看到另一个线程,其中提到如果从单实例启动模式的活动。所以我想知道我的替代方案是什么。
我的用例如下:我的应用程序侦听一个事件,当该事件发生时,它会显示一个警报对话框,即使用户正在使用另一个应用程序也是如此。从其他 问题 我发现常见的执行此操作的方法是使用 singleInstance 启动模式启动活动。但现在一旦弹出此警报对话框,我需要使用 RecognizerIntent 并对文本进行一些语音处理。然而,语音输入对话框不会等待任何输入,并且会立即调用 onActivityResult()。如果我的警报对话框从具有“singleInstance”之外的启动模式的活动中弹出,则一切正常。
还有其他方法可以解决这个问题吗?
Already saw another thread which mentions that an activity with RecognizerIntent was not working correctly if launched from within an activity with singleInstance launch mode. So I would like to know what my alternatives are.
My use case is as follows: My application listens for an event, and when this event occurs, it displays an alert dialog, even if the user is in the midst of using another application. From other questions I found that the common way of doing this is to launch an activity with singleInstance launch mode. But now once this alert dialog pops up, I need to use RecognizerIntent and do some speech to text processing. However speech input dialog just does not wait for any input and onActivityResult() is called immediately. Things work fine if my alert dialog pops up from an activity which has a launch mode other than "singleInstance".
Are there other ways to approach this problem ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以这种方式运行您的代码:-
上面的代码应该写在 onCreate() 内部,而下面的代码应该写在 onCreate() 之外,
我已经在 DellXCD35 android 2.3.3 上测试了它,一旦您在列表中查看文本列表,它就可以很好地工作由您选择。
Try running your Code this way :-
Above code should be written inside onCreate() while below should be written ouside it
I have tested it on DellXCD35 android 2.3.3 and it works perfectly well once you get list of texts in your list view it upto you whihch you want to select.