Android 为什么我的可搜索活动是';s Intent.getAction()为空?

Android 为什么我的可搜索活动是';s Intent.getAction()为空?,android,search,action,android-intent,Android,Search,Action,Android Intent,我已经按照文档进行了操作,但仍无法搜索我的应用程序的活动之一。在“我的活动”中,会出现“搜索”对话框,我输入查询,点击“搜索”,我的活动将重新打开,然后我在日志中看到: D/SearchDialog( 584): launching Intent { act=android.intent.action.SEARCH flg=0x10000000 cmp=com.clinkybot.geodroid2/.views.Waypoints (has extras) } I/SearchDialog(

我已经按照文档进行了操作,但仍无法搜索我的应用程序的活动之一。在“我的活动”中,会出现“搜索”对话框,我输入查询,点击“搜索”,我的活动将重新打开,然后我在日志中看到:

D/SearchDialog(  584): launching Intent { act=android.intent.action.SEARCH flg=0x10000000 cmp=com.clinkybot.geodroid2/.views.Waypoints (has extras) }
I/SearchDialog(  584): Starting (as ourselves) #Intent;action=android.intent.action.SEARCH;launchFlags=0x10000000;component=com.clinkybot.geodroid2/.views.Waypoints;S.user_query=sdaf;S.query=sdaf;end
I/ActivityManager(  584): Starting activity: Intent { act=android.intent.action.SEARCH flg=0x10000000 cmp=com.clinkybot.geodroid2/.views.Waypoints (has extras) }
D/WAYPOINTS( 1018): NI Intent { cmp=com.clinkybot.geodroid2/.views.Waypoints (has extras) }
D/WAYPOINTS( 1018): NI null
D/WAYPOINTS( 1018): NI false 
在我看来,直到最后三行,一切都很好。“NI”行分别是
getIntent().toString()、getIntent().getAction()
getIntent().hasExtra(SearchManager.QUERY)

ActivityManager似乎正在以正确的操作开始我的活动。那么当我的活动开始时,它不包含任何操作!?我做错了什么

我的舱单的相关部分是:

<activity android:name=".views.Waypoints" android:label="Waypoints" android:launchMode="singleTop">
   <intent-filter>
    <action android:name="android.intent.action.SEARCH" />
    <category android:name="android.intent.category.DEFAULT" />
   </intent-filter>
   <meta-data android:name="android.app.searchable"
    android:resource="@xml/searchable" />
  </activity>

这花了我太多的时间。当从可搜索的singleTop活动(在我的例子中是Waypoints)执行搜索时,必须覆盖onNewIntent()并在那里获取搜索查询。进去几个小时后,我就开始做了。问题是getIntent()不返回用于调用活动的意图(头部爆炸)。它似乎返回了在我执行第一次搜索之前打开我的可搜索活动的原始意图

接收到搜索意图。我用onNewIntent()和boom,progress中的参数替换了getIntent()


虽然我必须承认;弄明白了这一点,就可以减轻无法逃避与背景中的星星一起跳舞的声音的沮丧情绪。

我很高兴在我的脑袋爆炸之前发现了这个问题。《应用程序基础指南》中提到了这一点,但如果在中提到onNewIntent而不是仅在中,那就太好了。此外,的文档甚至没有提到任何内容!!!啊。。。也就是说,谢谢。因此,始终从onCreate调用onNewIntent(getIntent())可能是一个很好的做法,只是为了让您知道它遵循相同的代码路径。这里解释了您的问题,但是即使应用了此方法,我仍然会得到null。。。