2010-01-07 41 views
6

我正试图抓住Android电子市场的搜索意图。捕捉市场搜索意图?

这是你推出Android市场,并通过包名称搜索应用程序的方式:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pname:com.google.somepackage"))); 

现在,这里是我的活动之一的意图过滤器:

<intent-filter> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <data android:scheme="market" android:host="search" /> 
</intent-filter> 

我期望Android问我哪个应用程序应该处理不发生的意图。
但是,如果我用market1search替换marketsearch1,在这两个地方,我的活动都会启动。
有没有“不可触摸”的意图或什么的概念?

TIA。

回答

8

这确实很奇怪,有点违背整个开放意图系统。我知道只有系统可以创建广播,但我没有听说过这样的意图解决。

无论如何,我只是在我的HTC Hero上放弃了Market APK,并检查了清单。他们通过添加路径是在他们的URI匹配略微更加具体:

<intent-filter android:priority="100"> 
    <action android:name="android.intent.action.VIEW" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <category android:name="android.intent.category.BROWSABLE" /> 
    <data android:scheme="http" 
      android:host="market.android.com" android:path="/search" /> 
    <data android:scheme="market" 
      android:host="search" android:path="" /> 
</intent-filter> 

不过,我尝试添加这我的应用程序,但我增加了优先级值(not that I've seen that have any effect before),但我还是没能捕获Intent

希望有人(或AOSP)可以摆脱对情况的一些光...

+13

通过设置优先级这样的,没有第三方应用程序可以拦截意图。只有安装在系统分区中的应用才能被授予大于0的优先级。 – hackbod 2010-01-07 23:35:32

+1

啊哈!非常感谢这些信息。 – 2010-01-07 23:51:35

+2

@hackbod会很好,如果可以添加到文档http://developer.android.com/guide/topics/manifest/intent-filter-element.html#priority – 2010-01-08 01:02:49