Possible to bypass Android Intent Filter? - android

In my app I have an intent filter set to match certain types of links if clicked in a web browser or other field. It currently looks 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="www.mydomain.com"
android:scheme="http" />
<data
android:host="mydomain.com"
android:scheme="http" />
<data
android:host="m.mydomain.com"
android:scheme="http" />
</intent-filter>
This works well. If you click a link say http://www.mydomain.com/article_name then the user gets the option of opening the article in the app and I can show the content uniquely. Here's the question - in the app I want to provide an option for the user to still break out and "Open in Browser". Yet if I do this and just try to fire off an intent to launch the browser, my app catches the link again and we go around in a circle.
How can I specifically force a link to be opened in the browser?

I believe you can use the answers provided in this thread to achieve your end. Basically, when you go to launch the "open in browser" intent, you can preview the activities that will be able to open it. From there, you can select one that isn't your app and set that as the package on the intent, which will cause the other app to open it.
At worst, you could force the creation of the chooser which would contain both your app and the other apps that can open your site, enabling the user to pick the browser.
This other question might also be useful, as its answers contain an implementation of a custom chooser which apparently allows you to filter the visible activities, so you could remove your app.

I don't know any way to bypass Android Intent Filter.
If user uses Android default Browser or Chrome, you should use the way in following link to open an Intent specifically.
https://developers.google.com/chrome/mobile/docs/intents

Related

Android - Setting the app's default "Open supported links" option

How can I control the default Open supported links to either Ask every time or Open in this app for my Android app? Does it happen in the manifest?
I have two apps that try to accept the same universal link scheme, and the ideal behavior is to have the user decide which app to open when they click on the link. However, it seems that the first app correctly has the Open supported links in settings set to Ask every time, while the other app has the Open supported links as Open in this app. Thus, when both apps are installed, only the second one will be opened straight away, whereas the first one won't even be prompted.
The portion that accepts universal links in both of the AndroidManifest.xml files are almost identical.
<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:host="foo.bar.com" android:pathPrefix="/action/" android:scheme="https" />
</intent-filter>

How to use only my app for intent-filter URL with specific prefix?

Suppose we have an activity to resolve external URL links with a specifix pathPrefix. It's not a problem. The problem is to have a method to make those links is only resolvable with my app.
For example:
We have this 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:host="example.com"
android:pathPrefix="/specific_prefix/"
android:scheme="http" />
</intent-filter>
And I want only my app to be used for example for "example.com/specific_prefix/etc". If that eve possible?
And I want only my app to be used for example for "example.com/specific_prefix/etc". If that eve possible?
No.
First, how URLs are interpreted is up to the app interpreting the URLs. Some Web browsers, when they encounter an http URL, will always handle it themselves, rather than seeing if a third-party app has advertised support for it.
Second, in cases where there are two or more apps that claim to support a certain operation, the user chooses which one to use. In your case, Web browsers and your app will claim to handle that URL, and the user can choose whichever of those that the user wants.
With Android 6.0's app links, you can avoid the chooser by default, so if a chooser would have appeared, the user will be taken straight to your app. The user can disable this in Settings, though.

Android Intent Filter to receive image files is only working in some apps

I'm experimenting with android development. As an exercise I want to create an app that is able to receive images shared by other apps. I'm testing the app on my phone.
If i share an image in WhatsApp everything works as expected. My app is listed in the share dialogue and the activity is started. But if try to share an image from any other app (e.g. Photos, Album, Gallery) my app is not listed as on of the options.
I'm using a standard Android Studio project and added only the following lines to the manifest.
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="ANDROID.INTENT.CATEGORY.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Why isn't my app listed in the other apps? What do I have to change to make it work?
Android is case-sensitive. By having ANDROID.INTENT.CATEGORY.DEFAULT, you will not match any Intent that is seeking android.intent.category.DEFAULT. Change the case to android.intent.category.DEFAULT, and you will match more activity requests.
In fact, since android.intent.category.DEFAULT is added by default to Intent objects passed to startActivity() or startActivityForResult(), I am not quite certain how your activity worked with WhatsApp...

How to use web app to share content in mobile?

I couldn't find anything on this. I read everything about protocol/content handlers but didn't seem to solve my problem at all.
I'm trying to find a way to allow an Android user (for example) to share content using a web application.
Examples:
1) Viewing a Youtube video in the native app. User selects 'share' and a bunch of icons appear. I want my web app to be there, so when user selects its icon, a URL is opened in the browser with a magic parameter passing the video URL so I can handle that.
2) Well, you get the idea now :)
Any ideas?
Thanks.
If your app can do some task and you want that message to be conveyed to all other apps, Android way of doing this is - Intent Filters (It tells the world what the app can do)
Intent - Android way of telling - Hey i want to get this job done ?
If you build a social app that can share messages or photos with the user's friends, your app should support the ACTION_SEND intent. so users can initiate a "share" action from another app and launch your app to perform the action.
To allow other apps to start your activity, you need to add an element in your manifest file for the corresponding element.
If your activity handles both text and images for both the ACTION_SEND and ACTION_SENDTO intents. In this case, you must define two separate intent filters for the two actions because a ACTION_SENDTO intent must use the data Uri to specify the recipient's address using the send or sendto URI scheme. For example:
<activity android:name="ShareActivity">
<!-- filter for sending text; accepts SENDTO action with sms URI schemes -->
<intent-filter>
<action android:name="android.intent.action.SENDTO"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="sms" />
<data android:scheme="smsto" />
</intent-filter>
<!-- filter for sending text or images; accepts SEND action and text or image data -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*"/>
<data android:mimeType="text/plain"/>
</intent-filter>
</activity>
This link has all the above mentioned details with lot more information.
http://developer.android.com/training/basics/intents/filters.html

How to add app to "Share via" list for camera picture on Android

I am building an app that starts when a user takes a picture using their build-in Android camera, then taps the Share button, then chooses my app as the sharer, which is expecting an incoming path to the picture that was just taken, which it uses for processing.
Question: how do I add an option to the "Share via" list that points to my app? Right now there are options like Facebook, Email, Messages, Twitter, Picasa, and I want to add my app w/ an icon.
I'm stuck! And, Google'ing for this is not easy, as "android add to share via list camera" yields a lot of results. I'm building the app with AppInventor (AI), but, AI does not allow developers to edit the Share via list, so maybe this will have to be a separate mini app that just adds to the list...? Hopefully not, because it'd be great to have just 1 app for users to download/install.
Functions like the "share via" in Android work with broadcast intents. The app creates this intent and the system reports all the activities that can execute that (twitter, fb...) You specify what an activity can do by means of intent filters.
In your case I searched for "android camera share intent" and found generally that the intent filter looks like this:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
(not sure about the data section)
I don't know if camera app uses a specific content provider, anyway your app should be able to manage at least the URI scheme that app uses.
I wanted to Share text content and i add the below code in manifest and its works...
<activity android:name=".SendMessage.SendMessageLeads"
android:label="SMS Composer"
android:icon="#drawable/sms_composer">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>

Categories

Resources