windows用浏览器打开应用程序的方法
找到应用程序所在的文件位置:
C:\Program Files (x86)\OSS\oss.exe
新建
regeit.reg
文件内容如下:(路径需要双斜线)1
2
3
4
5
6
7
8
9
10
11
12
13
14
15Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\oss]
@=""
"URL Protocol"="C:\\Program Files (x86)\\OSS\\oss.exe"
[HKEY_CLASSES_ROOT\oss\DefaultIcon]
@="C:\\Program Files (x86)\\OSS\\oss.exe"
[HKEY_CLASSES_ROOT\oss\Shell]
[HKEY_CLASSES_ROOT\oss\Shell\Open]
[HKEY_CLASSES_ROOT\oss\Shell\Open\Command]
@="\"C:\\Program Files (x86)\\OSS\\oss.exe\" -e %1"保存后双击运行该文件
在浏览器打开,如下添加 a 标签即可
1
<a href="oss://yourparams">打开oss</a>
移动H5页面通过scheme打开本地APP
在 Android 中声明实现 scheme,首先需要在Android工程的 Manifest文件,给想要接收跳转的Activity添加 intent-filter 节点的配置拦截器规则
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22<activity
<!--定义响应该scheme协议的 activity 的名称 -->
android:name=".DeepLinkActivity"
<!--需要添加下面的intent-filter配置-->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<!--scheme 允许在浏览器中打开-->
<category android:name="android.intent.category.BROWSABLE"/>
<!--scheme 相关信息配置-->
<data android:scheme=""
android:host=""
android:port=""
android:path=""
android:mimeType=""
android:pathPattern=""
android:pathPrefix=""
android:ssp=""
android:sspPattern=""
android:sspPrefix=""/>
</intent-filter>
</activity>在相应的 activity 可以获取 uri 中参数
1
2
3
4
5
6
7
8
9
10
11
12
13
14public class DeepLinkActivity extends AppCompatActivity {
private static final String TAG = "DeepLinkActivity";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = getIntent();
Log.e(TAG, "scheme:" + intent.getScheme());
Uri uri = intent.getData();
Log.e(TAG, "scheme: " + uri.getScheme()); // 获取 scheme 名称
Log.e(TAG, "host: " + uri.getHost()); // 获取 scheme 的host
Log.e(TAG, "path: " + uri.getPath()); // 获取 scheme 的路径
}
}在一个 a 标签中打开