I am working on article reader and am trying to accept article urls from other apps (similar to how Pocket, Evernote are listed in the Share via menu as "Add to X").
My activity contains the following in the manifest:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAUlT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/*" />
</intent-filter>
But so far the app only shows up in the "Share via" list for Chrome(Android), but not for other apps that show articles (for example, it doesn't show up in the share list in the "Reddit Now" app whereas other apps like "Pocket" or "Evernote" do).
What do I have to specify to accept any kind of information that may potentially contain an article url?
Related
I have deployed an Android app that is designed to view files, some users reporting that my app isn't appearing when they try to open a file but does appear when selecting Open with....
For example, when I try to open a file in some apps I am presented with a dialog like this:
When I press Open with... I am presented with a dialog like this:
I think what is happening here is the Open with... is starting an ACTION_CHOOSER intent whereas pressing the file starts an ACTION_VIEW intent.
My questions are:
Is my assumption surrounding the ACTION_CHOOSER reasonable?
Why do some apps appear in ACTION_CHOOSER that don't appear in ACTION_VIEW?
Is the ACTION_VIEW list somehow dependent on a device?
If so, what would cause my app to not appear in this list?
For reference, my activity's intent filter looks like this:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="*"
android:mimeType="*/*"
android:scheme="content" />
<data
android:pathPattern=".*\\.xml"
android:scheme="file" />
<!-- about a hundred other file types -->
<intent-filter>
I've been implementing google app indexing in my app, though it's turning out to be very hard for me to understand.
I've created the following intent-filter in my app
<intent-filter android:label="#string/app_name">
<data android:scheme="android-app"
android:host="com.towers.mywebsite" />
<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="www.mywebsite.com" />
<data android:scheme="https"
android:host="www.mywebsite.com" />
</intent-filter>
I'd like to grab all the links like www.mywebsite.com?parameter=123 but NOT links like www.mywebsite.com/somethingelse
With the intent-filter above, my app is in the list of possible apps to open all the deep links like www.mywebsite.com...
My question is: am I doing it right? How am I supposed to filter the intent in order not to make all the links try and open tre app? I thought google would have chosen open-the-app-or-the-browser by checking which pages of my website do have the link rel attribute, but it seems like it only relies on my app intent-filter. Therefore, I need to tweak them in order to filter only the pages I want. How can I do that?
Thank you
You can rely on markups if you don't declare App-Website association.
https://developers.google.com/app-indexing/android/app#declare-a-website-association
You can also try controlling indexing by creating noindex.xml file to specify the URLs you want excluded from the Google index.
https://developers.google.com/app-indexing/android/app#noIndex
Cheers,
MB
I am developing an app that can extract information from certain web pages. The idea is that when the user is within a specific url path in the browser and press the share button, my app will show up in the list of receiver apps.
I can do that easily by adding this to the manifest:
<intent-filter android:label="#string/app_name" >
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
However, this will make my app appear on the list on all urls, also all those where it will have nothing to do. Instead I would like the app appear in the chooser only from these urls:
www.example.com/foo/bla.html
www.example.com/foo/bar/blabla.html
But not from these:
www.example.com
www.foobar.com
etc. Ie. only from within a certain path on a certain host. Also note that I do not want my app to be launched when the user clicks on links matching the criteria. It should only be invoked from the share menu.
So my question is: How can I limit my app to show up in the intent choose only for certain urls?
Add the following filter to the destination Activity ..
1. host your site name.
2. scheme scheme of your site http or https.
3. path for the file path your app should display.
<intent-filter>
<data
android:host="www.example.com"
android:scheme="http"
android:path="/foo/bla.html"
/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" >
</category>
<category android:name="android.intent.category.BROWSABLE" >
</category>
</intent-filter>
How can I limit my app to show up in the intent choose only for certain urls?
You can't. ACTION_SEND has no notion of "only from certain URLs", or "only from certain WhatsApp users", or "only from left-handed Alaskan pipe-welders".
This is not significantly different than any other activity. An <intent-filter> only controls what the Intent is being delivered to. Nothing controls what the Intent is delivered from, with the exception of security-related items (permissions, whether or not the component is exported, etc.).
So, with ACTION_VIEW, the URL is something being delivered to another activity ("I wish to view this URL"). This works because the URL is turned into the Uri of the Intent, and that can be filtered upon via <data> elements in the <intent-filter>.
But ACTION_SEND doesn't have to have a URL, and even if there is one, it is merely payload in the form of an extra. It is not something that can be filtered upon.
Hence, what you want is not supported.
Use pathPrefix
<intent-filter>
<data
android:host="www.example.com"
android:scheme="http"
android:pathPrefix="/foo/"
/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" >
</category>
<category android:name="android.intent.category.BROWSABLE" >
</category>
</intent-filter>
First of all, my question is extremely similar to this, this and this. The Android documentation for what I'm trying to achieve is here. I couldn't get this to work using these resources so please don't mark this as duplicate as it is not.
I have a website and an Android application. The user will be able to scan QR codes that contain links like http://mywebsite.com/map/. When the user tries to open this link, I want Android to show him a chooser dialog where he can choose to open that link using my application. If my application is not installed, it should proceed to the specified website.
I know Chrome allows this by opening the chooser dialog when the user navigates to that address. For example, try downloading the Stack Exchange app and going to this question in Chrome. It will show this:
I have added the following code in AndroidManifest.xml after following the suggestion in the above-mentioned answers:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="mywebsite.com"
android:path="/map"
android:scheme="http" />
<data
android:host="mywebsite.com"
android:path="/animals"
android:scheme="http" />
<data
android:host="mywebsite.com"
android:path="/articles"
android:scheme="http" />
</intent-filter>
Also, I have tried adding android:mimeType="text/plain" to data but it didn't help.
The problem is that when I go to http://mywebsite.com/map or http://mywebsite.com/map/ Chrome just opens the webpage without showing the chooser dialog.
I would like to mention:
following the Android documentation, I have added this code inside one of the activity structures in AndroidManifest.xml. As I am not sure this is the perfect place to add it, I have also tried adding it outside the application structure and directly inside the application structure but it didn't work
this is the only code I have implemented for this to work. If something else is needed please let me know. From what I understand, adding a href to the webpage is only needed when using custom schemas
I do not want to use a custom schema in order to achieve this
I am developing on a Nexus 4, running Android 4.4.2 (latest)
You need to set it up like this :
<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:host="example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
</intent-filter>
Notice that in your case, you would need to use android:pathPrefix instead of android:path.
Just to be sure, you should reset the preferences for your app in case you have accidentally set it to always open the link in chrome rather than show the chooser dialog. Once "Always" is used to open the matching uri, it will never show the chooser.
Second, you can have as many data elements in the intent filter as your want, but it is not necessary to repeat information. You can do the same thing like this:
<data android:host="mywebsite.com"/>
<data android:scheme="http"/>
<data android:path="/map"/>
<data android:path="/animals"/>
<data android:path="/articles"/>
But note that for the path, you can just use a wildcard
<data android:path="/.*"/>
Consider adding an additional
<data android:host="www.mywebsite.com"/>
And finally you may not want to show the chooser dialog but open a specific app intent/activity directly. On your website, if you detect the android user agent, you can create a link url this way:
<a href="intent://mywebsite.com/articles#Intent;package=com.myapp;scheme=http;end;"/>
See here for more details How do I open any app from my web browser (Chrome) in Android? What do I have to do with the A Href link?
Note that with this method if the app is not installed the user will be taken to the Google Play store for the specified app package.
If you are still having problems, check your intent filter priority. http://developer.android.com/guide/topics/manifest/intent-filter-element.html
In my case site URL is: http://www.example.org/mobile/
so putting these code into AndroidManifest.xml inside 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:host="www.example.org"
android:pathPrefix="/mobile/"
android:scheme="http" />
</intent-filter>
Here,
scheme -> Protocol of particular site
host-> Exact site url with WWW
pathprefix - > Your site's sub path if available
Now,
You can search with chrome / etc android browser'search box like example then open chosen dialog ..!!
The following works fine:
I click on the link www.mycompany.com in an email and it starts my app:
<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:host="www.mycompany.com/download" android:scheme="http"/>
</intent-filter>
However, what I want to work is as below but it's not working:
I want to be able to restrict it to the link www.mycompany.com/download:
<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:host="www.mycompany.com/download" android:scheme="http" />
</intent-filter>
Why the distinction? I don't want to block my entire website with the app. I just want that specific domain to redirect to the app. How do I do that?
What you've shown is not a subdomain. That is,
www.mycompany.com/download
is not a subdomain of
www.mycompany.com
But you could use a subdomain to address this issue by setting up something like
download.mycompany.com
and have it map to www.mycompany.com/download. (Most servers allow you to set up subdomains like that.) You can then modify the intent filter accordingly.
EDIT
To support what you're trying to do without setting up a subdomain, you can do the following:
<data
android:host="www.mycompany.com"
android:scheme="http"
android:pathPrefix="download"
/>
I would suggest you to try latest feature made available by Google and that is App-indexing to show your app even when user search about your website on Google.
You need to go through 2 steps:
1 Sign Up for this feature here
2 Update your app as well as sitemap of your website as mentioned here
For further reference you can go through this documentation
Screenshot :