从网络打开 android 个应用

Open android app from web

我想从网络 link 打开我的 xamarin android 应用程序。我在 Activity class:

中添加了以下意图代码
[IntentFilter(new []{ Intent.ActionView },
    Categories = new []
    {
        Android.Content.Intent.CategoryDefault,
        Android.Content.Intent.CategoryBrowsable
    },
    DataScheme = "https",
    DataHost = "CinCardReader.Droid")]

用于打开应用程序的 HTML 文件是:

<html>
<title>Open Android Application</title>
<head> 
</head>
<body>
<a href="intent://CinCardReader.Droid/#Intent;scheme=launch;package=CinCardReader.Droid;S.content=WebContent;end">Open Application</a><br>
</html>

如果有人能帮助我修复错误,我将不胜感激。现在,当我点击 link 时出现错误:net::ERR_UNKNOWN_URL_SCHEME

尝试在清单文件中为此编写如下代码,然后您将能够管理 URL 并从浏览器打开应用程序。

     <activity android:name=”MainActivity”>
        <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:scheme="http" android:host="www.your_domain.com" />
        <data android:scheme="https" android:host="www.your_domain.com" />
        </intent-filter>
     </activity>

手动编辑清单文件,您将在解决方案文件夹的 Properties 文件夹中找到该文件。添加以下代码

<activity android:name="MainActivity">
            <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="my_scheme" android:host="my_host" />
            </intent-filter>
        </activity>

您 url 在浏览器中将是:

<a href="intent://my_host/#Intent;scheme=my_scheme;end">Open Application</a><br>

如果你有一个独特的方案,你不需要包名。 link 将搜索方案并打开应用程序。我试过了,它在 Xamarin 中工作。

如果您想要打开自定义操作,那么此 link 会对您有所帮助。