Android的:如何宣布任何活动为主要和搜索? [英] Android: how to declare an activity as main and searchable?

查看:141
本文介绍了Android的:如何宣布任何活动为主要和搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的主要活动是搜索的同时,但是当我在manifest.xml的改变

I would like my main activity to be searchable also but when I change the manifest.xml to

 <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
       <!-- declare the default searchable Activity for the whole app -->
       <action android:name="android.intent.action.SEARCH" />            
 </intent-filter>

它不能找到主要活动和应用程序不运行。 任何想法? 是它不使用相同的活性也可搜索的最佳实践? 谢谢, 阿利萨

it cant find the main activity and the application doesn't run. any idea? is it not best practice to use the same activity as searchable also? Thanks, Alisa

推荐答案

您需要添加一个新的意图过滤器与action.SEARCH

You need to add a new intent-filter with the action.SEARCH

<activity
    android:name=".activities.YourActivity">
    <intent-filter>
                <category android:name="android.intent.category.LAUNCHER" />
                <action android:name="android.intent.action.MAIN" />
    </intent-filter>
     <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
    </intent-filter>
</activity>

这篇关于Android的:如何宣布任何活动为主要和搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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