gpt4 book ai didi

Chrome : "Item not found" 的 Android Intent

转载 作者:行者123 更新时间:2023-11-29 17:29:06 24 4
gpt4 key购买 nike

我正在尝试从 Chrome 打开我的应用程序,但它对我不起作用..

这是官方(非常有限)的文档: Android Intents with Chrome

我发现了很多类似的问题,但似乎没有一个解决方案对我有用——而且,答案有点零散,所以我正在寻找带有示例的完整答案。一找到我的完整解决方案,我很乐意发布:)

这是我现在得到的:

AndroidManifest.xml:

<activity android:name=".ActMain" >
<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:scheme="http" />
<data android:scheme="https" />
<data android:scheme="sharedr" />
<data android:host="pocketr.rejh.nl" />
<data android:pathPattern="/.*" />
</intent-filter>
</activity>

Javascript(它在用户点击元素时构建 Intent 链接):

var url = "http://icerrr.rejh.nl/"
var title = "Example"
var intenturl = "intent://sharedr/#Intent;"
+ "package=com.rejh.sharedr;"
+ "S.action=share;"
+ "S.type=url;"
+ "S.title="+ app.helpers.encodeURIComponent(title) +";"
+ "S.url="+ app.helpers.encodeURIComponent(url) +";"
+ "end";
alert(intenturl); // for debugging
try {
window.location.href=intenturl;
} catch(e) { alert(JSON.stringify(e)); }

我从这个函数得到以下“链接”:

intent://sharedr/#Intent;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end

人类可读:

intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end

因此它的工作原理如下:它打开 Play 商店并显示“找不到项目”和一个刷新按钮。所以它打开了一个 Activity ,但不是正确的 Activity ..

我试图从中触发的网站是 http://pocketr.rejh.nl

帮忙吗?

完整答案

正如下面 Mattia 所指出的(我自己想出了这个问题,但找到了等待我的答案......:P)

首先:我忘记在我的 Intent 链接中包含“scheme=sharedr”:

intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end

应该是(注意第二行):

intent://sharedr/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end

然后,在 android list 中:

<activity android:name=".ActMain" >
<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:scheme="sharedr" android:host="sharedr" android:path="/"/>
</intent-filter>
</activity>

其中 'android:scheme="sharedr"' 是 'scheme=sharedr' 部分, 'android:host="sharedr"' 对应于 'intent://sharedr/'

谢谢!

最佳答案

您将 sharedr 指定为 hostAndroidManifest.xml 中配置的 hostpocketr .rejh.nl。您也没有指定 scheme

固定的 URL 是这样的:

intent://pocketr.rejh.nl/#Intent;scheme=sharedr;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end

人类可读:

intent://pocketr.rejh.nl/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end

关于Chrome : "Item not found" 的 Android Intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33707828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com