在同一 Activity 中在 Android 上执行搜索
我正在尝试将搜索集成到我的应用程序中,但我被一个问题阻止了。我的活动是这样声明的,位于 TabActivity 内部。
<activity
android:name="FileBrowserActivity"
android:screenOrientation="portrait"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
正如你所看到的,它的 launchMode 设置为 singleTop。但是,当我调用搜索时,输入搜索查询并按 Enter 键,会启动此类活动的另一个实例。没有调用 onNewIntent!但在启动的活动中,每个新搜索不会启动新活动。
期望的行为是保持在当前活动范围内。基本上这就是 android 启动器搜索的工作原理。
I'm trying to integrate search in my app but I'm being blocked by one issue. My activity is declared like this and is located inside of TabActivity.
<activity
android:name="FileBrowserActivity"
android:screenOrientation="portrait"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
As you can see its launchMode is set to singleTop. But when I invoke search, input the search query and press enter another instance of such activity is launched. No onNewIntent is being called! But in the launched activity each new search doesn't launch a new activity.
The desired behaviour is to stay within current activity. Basically that's how android launcher search works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用
android:launchMode="singleTop"
就像所描述的 在本文中。You should rather use
android:launchMode="singleTop"
like described in this article.您可以使用 android:noHistory http://developer.android.com /guide/topics/manifest/activity-element.html#nohist
You could use android:noHistory http://developer.android.com/guide/topics/manifest/activity-element.html#nohist