application is not intercepting url - android

I am trying to intercept my own app's URL on android so that the user can open the URL in the app rather than on the browser. (I don't have browser support yet).
This is what I'm doing
<activity android:name=".ui.activity.MainActivity" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PICK_ACTIVITY" />
<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" />
<data android:host="myapp.com" />
<data android:pathPattern=".*"/>
</intent-filter>
</activity>
For some reason anytime I open myapp.com it still keeps opening in the browser, without giving me the option to open the URL in my app. I am trying this on my emulator with API 16 running on it. I've closed the emulator several times and started it again but still its the same behavior.
To avoid any errors in the URL of my personal app. I even experimented with:
<data android:host="goo.gl" android:scheme="http" />
<data android:host="goo.gl" android:scheme="https" />
The app DOES intercept the above url but ONLY the first time. If I click 'JUST ONCE' in the options presented, I don't get the option ever again until I restart the emulator.
Has anyone gone through this? What might I be doing wrong?

this answer helped me : link to question
if you add the package name to the intent, it will open your app by default

Related

Deep linking Android from chrome

The app opens when I load from applications. However, it does not load when I try to load from he chrome. This his is my manifest file
<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="http"
android:host="spectacles"/>
</intent-filter>
Take a look at this answer:
"Essentially, the Chrome team feels that if a user actually types something into the address bar, no redirect should ever happen. As you've discovered, this is counter to behavior in all other browsers."

android browser does not launch app

I am unable to get the app I have written to launch when a certain url is passed back to the browser.
When the user launches the default browser and goes to the where my server is running for example: www.test.com, a list of films and books are displayed on the remote server. When the user selects one of these items i.e. a film or book - the server sends back a url that starts with bb:// and contains the uri link.fil?data=1. So the url looks like this when sent back from the server:
bb://link.fil?data=1
Currently I have the manifest which declares the following filter intent:
<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="bb"
android:host="test.com"
android:path="/.*"
android:pathPattern="/.*\\.*"/>
/>
<data
android:scheme="bb"
android:host="www.test.com"
android:path="/.*"
android:pathPattern="/.*\\.*"
/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
What I am trying to make happen is when the user selects a book of film the returning url launches my app.
After following many of the examples on line I still don't seem to be able to get this to work, and would appreciate any help you can provide.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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="link.fil"
android:scheme="bb" />
</intent-filter>
The issue lay with chrome and mozilla they were rejecting the invocation - when using the default browser on android the app was called from the browser as was required. So I am marking the previous answer as correct but the problem lies with iframe which chrome and mozzila are now using- Maybe some one has the answer for fixing these exceptions?

Opening the custom file format in my application instead of downloading it on Android

When user type the url to my .someExt file in his web browser (on Android Phone), the message appears:
This content is unsupported content. Do you really want to download?
Instead, I would like to associate the .someExt (my custom file extension) with my Android Application (that the user has downloaded previously) so when user type the url to .someExt in browser my Application will open the file.
How to achieve it? I guess it has to be done with manifest and some "handle" method in my Activity.
Based on: Associate App with file extension - Intent filter Not working?
I have used:
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:mimeType="application/someExt" />
</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="*" />
<data android:scheme="file" />
<data android:scheme="smb" />
<data android:scheme="content" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.someExt" />
</intent-filter>
</activity>
Now, when user type the url to my .someExt the file is being downloaded and I can open it when downloading is done (so my Application will run it). But I don't want all those additional clicks - I want it to be:
User click the link to .someExt on the website.
The .someExt opens in my Android Application.
And not the:
User click the link to .someExt on the website.
The file starts to download.
User open "downloads" and click on downloaded file.
The .someExt opens in my Android Application.
I don't think you can realize this feature in Android with different kind of browsers. The URL user type is handled by the browser most of the time. How to deal with the scheme is decided by the behaviors of the browser. If your scheme is http, the browser will try to open with it own and handle by itself.
Currently, most browsers add support for market scheme. If the URI's scheme is market, it will jump to Google Play or other markets.
But is can be done from other app with Intent.
Declare your activity like following to receive the ACTION_VIEW action.
<activity
android:name=".MainActivity2Activity"
android:label="#string/title_activity_main_activity2">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="com.example.myapp"
android:mimeType="*/*"
android:pathPattern=".*\\.someExt"
android:scheme="http" />
</intent-filter>
</activity>
From other apps, you could do like this.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://com.example.myapp/test.someExt"), "*/*");
intent.setPackage("com.example.myapplication");
startActivity(intent);

App does not open when run scheme on Chrome/Firefox

I want to start my Android app by using scheme, this is my code:
<activity
android:name="com.myapp.SplashScreenActivity"
android:alwaysRetainTaskState="true"
android:label="#string/app_name"
android:noHistory="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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="www.myhost.com"
android:pathPrefix="/company/"
android:scheme="http" />
<data
android:host="myhost.com"
android:pathPrefix="/company/"
android:scheme="http" />
</intent-filter>
</activity>
Then run : myhost.com/company/ on browsers and results:
Default internet browser: App open normally
Chrome: does not work
Firefox: does not work.
I don't know how to solve it, please help me and explain me about it.
You should not use "http" as the scheme, because Chrome and Firefox can handle this kind of URL they will not call other app to handle it. Instead, you can use a self-defined scheme such as "myprotocol" which can not be handled by those browser, they will call your app to handle it. You can run "myprotocol://myhost.com/company/" on Chrome to test it.

http scheme intent filter for link to app from web

This seems to be a typical problem and there seems to be a lot of differing behaviour, the problem I'm having though is that my scheme will launch the picker and allow me to choose my app when I hit a link in an email or a note on the device, but if I hit a link on a web page I can't seem to launch the app, don't even get the picker (I'v checked the "defaults" for the two browsers and none are set).
<activity
android:name=".MyActivity"
android:exported="true"
android:enabled="true">
<intent-filter>
<data android:scheme="http" android:host="www.website.com"/>
<data android:scheme="http" android:host="website.com"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
If I use one of my links from an email as below it gives me the chooser, launches my app, all is great, however, hitting the same link in the web browser just launches the page with no chooser. Any suggestions on what the problem might be?
http://www.website.com/share.aspx?id=12345678
Testing on GS2 running ICS 4.0.3 with Chrome and stock browsers.
Add the android:pathPrefix attribute.
<data android:scheme="http" android:host="website.com" android:pathPrefix="/" />
This is how I solved it eventually:
<intent-filter>
<data
android:host="www.website.com"
android:pathPattern=".*\\share.aspx"
android:scheme="http" />
<data
android:host="website.com"
android:pathPattern=".*\\share.aspx"
android:scheme="http" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Also add the following to the Activity tag:
android:exported="true"
The reason there are two addresses is so that the app can pick up canonical domains (with/without www.).

Categories

Resources