ori*_*yan 13 search android action android-intent
我已经按照SearchManager文档但仍然无法搜索我的应用程序的某个活动.从我的活动中,出现搜索对话框,我输入查询,点击搜索,我的活动重新打开,然后我在日志中看到:
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
Run Code Online (Sandbox Code Playgroud)
在我看来,直到最后三行,一切都很好.的"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>
Run Code Online (Sandbox Code Playgroud)
ori*_*yan 16
那花了我太多时间.从可搜索的singleTop活动(在我的案例中为Waypoints)中执行搜索时,您必须覆盖onNewIntent()并在那里获取搜索查询.几个小时之后,我在做什么.问题是getIntent()不返回用于调用活动的Intent(head explodes).在我执行第一次搜索之前,它似乎返回了打开我可搜索活动的原始Intent .
该onNewIntent方法接收搜索意图.我用onNewIntent()中的param替换了getIntent()和boom,progress.
虽然我必须承认; 想出这个可以减轻无法逃避与背景中的星星共舞的声音的挫败感.
| 归档时间: |
|
| 查看次数: |
4380 次 |
| 最近记录: |