17

I have a problem trying to launch my application from the browser using my own scheme.
Code is as follow:
Manifest file:

   <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" 
        android:exported="false">
        <intent-filter>

            <data  android:scheme="allplayer" />

            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Html file:

<html>
<head>
</head>
<body>
<a href="allplayer://site.com">Test link</a>
</body>
</html>

If I click on the link, my application wont start. I did a lot of researches, but couldn't find an answer.
If I change allplayer with http everything works fine.
From this link, I learnt that it is not recommended to use your own schemes.
Does that mean your own schemes wont work?
The person here is using his own scheme, and from his feedback it seems that it is working.
Am I missing something?

Lazy Ninja
  • 22,342
  • 9
  • 83
  • 103
  • 1
    What device are you testing on? There are reports of some devices not allowing custom URL schemes. – louielouie Oct 24 '12 at 02:57
  • @louielouie, I am testing on medias N-04D and aquos phone ST-12C with android ver 2.3.3 – Lazy Ninja Oct 24 '12 at 03:01
  • Since some devices do not allow custom schemes, I guess it is a no go. – Lazy Ninja Oct 24 '12 at 03:02
  • @LazyNinja ....hello sir...by yours above code, i only understand to handle the data from the link...Can you please tell me that how can i create a link which contains my data...please help me...I want to create the link with data on button click event.. – Ravindra Kushwaha Nov 30 '15 at 13:35

1 Answers1

32

It took me 6 hours to figure out the problem. Somehow setting the exported to false caused all the problem: android:exported="false". When I set it to true, it worked like a charm.

Funny because I put it there in the first place to avoid the Exported activity does not require permission warning. Setting it back to true, brought back the warning, but it is working now.

Solution is below. Hope it will help others save time.

<activity
      android:name=".MainActivity"
      android:label="@string/title_activity_main" 
      android:exported="true">
      <intent-filter>
          <data  android:scheme="allplayer" />
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.BROWSABLE" />
          <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
  </activity>
Lazy Ninja
  • 22,342
  • 9
  • 83
  • 103
  • 1
    all I did was to add android:exported="true" . It took me days, you're the man! – Andrei Cristian Prodan Dec 17 '13 at 14:29
  • 2
    I was on hour two with this problem. Thank you for bringing the exported value to my attention. It defaults to false. Curiously, it worked just fine without explicitly setting exported on Gingerbread. – Kevin Mark Dec 18 '13 at 07:37
  • Lazy Ninja : how can i open my application from bowser link pls. chekc my question [http://stackoverflow.com/questions/29982407/issue-in-open-my-application-from-browser-url-in-android/29982527#29982527](http://stackoverflow.com/questions/29982407/issue-in-open-my-application-from-browser-url-in-android/29982527#29982527) – Harshal Kalavadiya May 01 '15 at 06:30