从浏览器的URL方案启动应用程序应用程序、浏览器、方案、URL

2023-09-05 00:26:26 作者:空气中贪婪的血腥味道

由于许多好的帖子,我有蜜蜂尝试使用以下code浏览器链接启动我的Andr​​oid应用程序。请帮我调整清单,并HREF打电话给我的应用程序 -

清单

 < XML版本=1.0编码=UTF-8&GT?;
<舱单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
  包=com.afs
  安卓版code =1
  机器人:VERSIONNAME =1.1>
  <支持屏
  机器人:largeScreens =真
    机器人:normalScreens =真
    机器人:smallScreens =假
    机器人:调整大小=真
    机器人:anyDensity =真/>
<使用-权限的Andr​​oid:名称=android.permission.INTERNET对>< /使用-许可>
<使用-权限的Andr​​oid:名称=android.permission.CALL_PHONE>< /使用-许可>
<使用-权限的Andr​​oid:名称=android.permission.SEND_SMS>< /使用-许可>
<使用-权限的Andr​​oid:名称=android.permission.WRITE_SETTINGS>< /使用-许可>
<使用-权限的Andr​​oid:名称=android.permission.WRITE_EXTERNAL_STORAG​​E>< /使用-许可>
<使用-权限的Andr​​oid:名称=android.permission.MODIFY_PHONE_STATE>< /使用-许可>
<使用-权限的Andr​​oid:名称=android.permission.READ_PHONE_STATE>< /使用-许可>
<使用-SDK安卓的minSdkVersion =9>< /使用的SDK>
<应用机器人:标签=@字符串/ APP_NAME机器人:图标=@可绘制/ AFS机器人:可调试=真正的>
      <活动机器人:AFSNAME =
              机器人:标签=@字符串/ APP_NAME
              机器人:configChanges =keyboardHidden |定位
        机器人:screenOrientation =画像>
        <意向滤光器>
            <作用机器人:名称=android.intent.action.MAIN/>
            <类机器人:名称=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
         <意向滤光器>
             <数据机器人:计划=afs.com.afs/>
             <数据机器人:名称=android.intent.action.VIEW/>
             <类机器人:名称=android.intent.category.DEFAULT/>
             <类机器人:名称=android.intent.category.BROWSABLE/>
         &所述; /意图滤光器>
    < /活性GT;
< /用途>
 

HTML code

 < A HREF =afs.com.afs:75235>启动应用程序和LT; / A>
 

解决方案

从文档 方案://主机:端口/路径路径preFIX pathPattern

如何实现在网页中通过URL打开本地应用程序

您需要修改定义亲$ P $层方案和主机的定义。如果不指定计划,则所有的URI属性将被忽略,并且不会应用。

您可以使用 HTTP URI方案。

<数据机器人:计划=HTTP机器人:主机=afs.com.afs/>

和在HTML

< A HREF =HTTP://afs.com.afs:75235>启动应用程序和LT; / A&GT ;

或定义自己的URL方案。

<数据机器人:计划=MyApp的机器人:主机=afs.com.afs/>

和HTML中

 < A HREF =的myapp://afs.com.afs:75235>启动应用程序和LT; / A>
 

PS。

更改此

 <数据机器人:名称=android.intent.action.VIEW/>
 

<作用机器人:名称=android.intent.action.VIEW/>

Thanks to many good posts, I have bee trying to launch my Android app from a browser link using the following code. Please help me adjust the manifest and href to call my application -

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.afs"
  android:versionCode="1"
  android:versionName="1.1">
  <supports-screens
  android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="false"
    android:resizeable="true"
    android:anyDensity="true"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-sdk android:minSdkVersion="9"></uses-sdk>
<application android:label="@string/app_name" android:icon="@drawable/afs"        android:debuggable="true">
      <activity android:name=".afs"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
         <intent-filter>
             <data android:scheme="afs.com.afs"/>
             <data android:name="android.intent.action.VIEW" />
             <category android:name="android.intent.category.DEFAULT" />
             <category android:name="android.intent.category.BROWSABLE" />
         </intent-filter>    
    </activity>
</application>

HTML code

<a href="afs.com.afs:75235">Launch Application</a>

解决方案

Attributes from documentation scheme://host:port/path or pathPrefix or pathPattern.

You need to change define proprely scheme and host definition. If you don't specify scheme then all URI attributes will be ignored, and won't be applied.

You could use http URI scheme.

    <data android:scheme="http" android:host="afs.com.afs"/>

and in HTML

<a href="http://afs.com.afs:75235">Launch Application</a>

Or define own URL scheme.

    <data android:scheme="myapp" android:host="afs.com.afs"/>

and in HTML

<a href="myapp://afs.com.afs:75235">Launch Application</a>

PS.

Change this

    <data android:name="android.intent.action.VIEW" />

to

    <action android:name="android.intent.action.VIEW" />