从浏览器链接推出Android应用浏览器、链接、Android

2023-09-12 07:23:42 作者:花间一壶酒

我有一个问题想利用我自己的方案浏览器中启动我的应用程序。 code是如下: 清单文件:

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文件:

Html file:

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

如果我点击链接,我的应用程序无法启动。我做了很多的研究,但未能找到答案。 如果我改变的 allplayer 是 HTTP 一切工作正常。 从此链接,我才知道这是不推荐使用自己的计划。这是否意味着自己的计划不会工作? 这里的人是用他自己的方案,并从他的反馈看来,这是工作。 我失去了一些东西。需要你的帮助。 先谢谢了。

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. Need your help. Thanks in advance.

推荐答案

我花了6小时,以找出问题。不知怎的,设置导出为false引起的一切问题:安卓出口=假。当我将它设置为true,它的工作就像一个魅力。

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>
 
精彩推荐
图片推荐