来电onSearchRequested()在处理搜索请求相同的活动方法导致重复的活动栈 [英] Call to method onSearchRequested() in the same activity that handles search requests causes duplication in activity stack

查看:318
本文介绍了来电onSearchRequested()在处理搜索请求相同的活动方法导致重复的活动栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与SearchManager的处理搜索请求的活动,它的工作就好了。让我们把这个活动MySearchActivity.java。问题是,这次活动中,我有一个按钮,即与onSearchRequested()。

I have an activity that handles search requests with the SearchManager and it's working just fine. Let's call this activity MySearchActivity.java. The problem is that within this activity, I have a button that invokes the search request dialog with a call to onSearchRequested().

如果MySearchActivity.java是在活动堆栈中的当前任务和用户水龙头这个活动调用onSearchRequested(内的图标),本次活动是在其本身上再次推出。所以活动叠层内,我有两个相同的活动对彼此的顶部上。

If MySearchActivity.java is the current task in the activity stack and the user taps the icon within this activity that calls onSearchRequested(), this activity is re-launched on top of itself. So within the activity stack, I have two of the same activities on top of each other.

我不希望使用Android:noHistory在清单这项活动,并不能找到任何其他合适的标志想什么,我完成

I don't want to use android:noHistory in the manifest for this activity, and can't find any other suitable flags for what I'd like to accomplish.

我想,如果用户点击在MySearchActivity.java它调用调用onSearchRequested(),该活动不重复自己在堆栈中。图标

I would like that if the user taps the icon in MySearchActivity.java which invokes the call to onSearchRequested(), that the activity not duplicate itself in the stack.

我知道我可能忽视的东西或使这个复杂得多,它确实是....任何想法?

I know I'm probably overlooking something or making this more complicated than it really is....any ideas?

推荐答案

有关你可能需要设置启动模式解决singleTop的活动(例如机器人:launchMode =singleTop)。下面是进一步explenation @ 文档。祝你好运!

For the solution you probably have to set launch mode to "singleTop" for activity (e.g android:launchMode="singleTop"). Here is the further explenation @documentation. Good luck!

这篇关于来电onSearchRequested()在处理搜索请求相同的活动方法导致重复的活动栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆