Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

android - Catching market search intents?

I'm trying to catch an Android Market search intent.

That's the way you launch Android Market and search for an app by package name:

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

Now, here's the intent filter for one of my activities:

<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>

I'd expect Android to ask me which app should handle the intent which doesn't happen.
Yet, if I replace market with market1 or search with search1, in both places, my activity gets launched.
Is there a notion of "untouchable" intents or something?

TIA.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That is odd indeed, and kinda goes against the whole open intent system. I know there are broadcasts that only the system can create, but I hadn't heard of such a thing for intent resolution.

Anyway, I just dumped the Market APK on my HTC Hero and checked the manifest. They're being slightly more specific in their URI-matching by adding the path:

<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>

However, I tried adding this to my app, except I increased the priority value (not that I've seen that have any effect before), yet still I couldn't capture the Intent.

Hopefully someone (or the AOSP) can shed some light on the situation...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...