Catching market search intents? - android

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.

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

Related

I have set my flutter app for deep links in Android, but when I tap on external link, it open my app as in-app popup. Why?

What I want to achieve is that if user tap on the link e.g. on Whatsapp:
HTTP://dev.mycompany.com/qr/asd89f7as98df78
This link will open my app supplied with the deep link.
But the issue is this link actually open my app inside the Whatsapp. So when I open the app switcher, it looks like there are two instances of my app opened. How can I fix this?
I suspect this has something to do with the way I configure my intent filter on Android Manifest. But I'm inexperienced with intent-filter. This is the current configuration for my intent filter(s):
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<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="dev.mycompany.com" />
<data android:scheme="https" />
</intent-filter>
Is there anything I can do to fix the problem? The first intent filter is the default when I create the app. The second one is from copy pasting from solutions I find on stack overflow. But I don't think this is the fully correct solution. I don't want the app to can be opened as popup.

Prevent multiple intent-filters from matching for oauth redirect

When receiving an OAuth redirect in my app, the Android "Open with" menu shows with 2 choices, both being my application. The desired behavior would be to simply proceed into the app without showing the "Open with" menu.
This issue started happening after I added a new intent-filter to capture "text/plain" shares from other applications.
Here are my intent-filter that are part of the same activity:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.app" android:host="app" android:pathPrefix="" />
<data android:scheme="com.app" android:host="oauth" android:pathPrefix="" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
And the Intent captured using adb logcat:
{act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=com.app://oauth?code=4pZliH2NrWWoypXnsBqEOjbMramW70&state=6AImyjKHt7ZhYPuk_pJjRQ flg=0x14000000 pkg=com.app cmp=android/com.android.internal.app.ResolverActivity (has extras)}
Since they are a part of the same activity I assumed that it wouldn't prompt the user to select an option. I also assumed action.VIEW would only match the first intent as well.
When attempting to combine intents, the redirect failed to work entirely. And from researching, it doesn't seem like there is a way to prioritize intents.
Any suggestions would be greatly appreciated. Thanks!
I have discovered the issue. I was using a library (AppAuth-Android) that was injecting its own ...
After removing the library, the issue was resolved. Thanks for the suggestion!
Check here
You are creating two schemes with same name in same intent-filter.

ACTION_SEND_MULTIPLE mime type filters seem completely broken

I'm currently building an app where I want to handle receiving shared images. Everything worked just fine with the ACTION_SEND, with the following declaration
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
In my manifest, but when I tried to do the same with ACTION_SEND_MULTIPLE, my share activity started being suggested when sharing mixes of video and images. I dug deeper and found out that the 'mimeType' received is */*, which the OS matches with image/*. So I did an experiment and tried the following configuration:
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
</intent-filter>
and wouldn't you know it, my activity started being suggested when selecting images and videos, even though they have nothing to do with PDFs.
What is the intended way to declare my application as being able to receive multiple images, and only images?

Android Intent for File Type Fails

This has been discussed in general previously, but I now have a specific case. My app opens a particular app-specific file type (.gedstar), which is actually a SQLite database and generally handled as application/octet-stream with a pathPattern qualifier. This is my Intent definition:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"
android:mimeType="application/octet-stream"
android:pathPattern=".*\\.gedstar"
android:host="*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file"
android:mimeType="*/*"
android:pathPattern=".*\\.gedstar"
android:host="*" />
</intent-filter>
(I've had it with and without the wildcarded mimeType, BTW). Up to now, I've been recommending the use of Dropbox to transfer the file from the user's PC to Android and launch my app, and this has been working well up until recently. Then, with the release of the Dropbox V2.0 app, it broke, resulting in the toast message about not having an app for this file type.
Trapping it with Logcat, this is the intent that does NOT work, which looks to me like it should:
I/ActivityManager( 97): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/Android/data/com.dropbox.android/files/scratch/GedStar%20Pro/Gordon.gedstar typ=application/octet-stream flg=0x10000003 (has extras) }
The strange thing is that I can download this same file using Dropbox's browser interface, then go to the browser's list of downloads and launch it successfully. Here is the SUCCESSFUL intent:
I/ActivityManager( 97): Starting activity: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/download/Gordon.gedstar typ=application/octet-stream flg=0x10000000 cmp=com.ghcssoftware.gedstar/.GedStar }
The only differences I see are the value of "flg" and the "cmp=" value which I assume is because the ActivityManager found a matching intent. Can anyone explain this more fully?
Thanks to Dropbox's tech support, it turns out that I was not the only one having this issue, and the reason is the "com.dropbox.android" in the Intent string, containing those extra dots. Turns out that the pathPattern matching is not "greedy" and thus is broken by the first dot in the spec. It would also break if the user has a dot in a directory or file name! The solution (do we still use the word "kludge"?) is to supply a bunch of intent filters with pathPatterns such as:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.ALTERNATIVE"/>
<data android:scheme="file"
android:mimeType="application/octet-stream"
android:pathPattern=".*\\..*\\..*\\..*\\.gedstar"
android:host="*" />
</intent-filter>
This matches a path with three dots preceding the ".gedstar" string. The idea would be to include multiple intents to cover as many dots as could be expected. Ugly, but it DOES work now!

Android: using intent filter to launch app doesn't work

I know this question is asked and answered many times on SO, but I just couldn't get it to work. Here is my manifest file (I have 3 activities, I'm showing the only one that I want to be displayed when associated):
<activity
android:name=".MyActivity"
android:label="#string/app_name"
android:theme="#style/HoloDarkTheme" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.ACTION_SEND" />
<action android:name="android.intent.action.EXTRA_TEXT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.action.BROWSABLE" />
<category android:name="android.intent.action.DEFAULT" />
<data android:scheme="http" />
<data android:host="example.com" />
</intent-filter>
</activity>
When I launch a browser and go to "example.com", my app isn't launched. Is there something wrong with the above XML?
Not sure if relevant, but this activity uses MediaPlayer to play videos. Also, I'm using SDK version 11.
I figured it out. It's simply a case of typo. Instead of this,
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.action.BROWSABLE" />
<category android:name="android.intent.action.DEFAULT" />
I needed to replace "android.intent.action" with "android.intent.category" in the last two lines:
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
I'm adding this answer here because this thread is one of the top hits when googling "intent filter to launch app from http not working". I suppose the root cause for me could also be considered a typo, but I'm going to call it an "Android documentation defect".
There's a line way toward the bottom of this page that breaks down a URI as:
<scheme>://<host>:<port>/<path>
This breakdown indicates that the "://", ":" and "/" will be added for me so I used the following data in my intent-filter:
<data android:scheme="http" />
<data android:host="my.school.edu" />
<data android:path="thingy" />
I then sent myself an SMS with the following text: "my.school.edu/thingy", which was recognized by my SMS client (Hangouts) as a web address, so it made it clickable. However, clicking on it just gave me a choice of browsers, my app was a no-show.
So I removed the host and the path, and my app launched for any link (or at least every one I tried). I put the host back in and it still worked. Put the path back and we're back to not working. On a whim I decided to prepend a slash to the path:
<data android:path="/thingy" />
...et voilĂ ! There's my app in amongst the browsers! So the error in my view is Android's doc that suggests that the slash is inserted automagically. :) It apparently is not.
More Info: I'm using the HTTP scheme because that's what gets made clickable in SMS and email messages, giving me a free ride to that point.
And note that if you specify a unique host (and path), and the user selects "Always" when choosing your app from the list, future taps on your link will bypass that choice dialog and go straight to your app, which is nice.
Make sure you have the internet permission in your manifest.
I doubt that you can override the http scheme to point back to your app.

Categories

Resources