当前位置 : 主页 > 编程语言 > java >

如何通过Html网页调用本地安卓app?

来源:互联网 收集:自由互联 发布时间:2023-03-22
​​微信如何通过Html网页调用本地安卓app 或者ios app?​​ android 端代码 ?xml version="1.0" encoding="utf-8"?manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.liuan.jsrunapp" applicatio

​​微信如何通过Html网页调用本地安卓app 或者ios app?​​

android 端代码

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.liuan.jsrunapp"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <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" /> <!--host可以不写--> <data android:scheme="ckck" /> </intent-filter> </activity> </application></manifest>package com.liuan.jsrunapp;import android.content.Intent;import android.net.Uri;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.widget.TextView;public class MainActivity extends AppCompatActivity { TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = (TextView) findViewById(R.id.tv_main_show); Intent intent = getIntent(); Uri uri = intent.getData(); if (uri != null) { String name = uri.getQueryParameter("name"); String scheme = uri.getScheme(); String host = uri.getHost(); String port = uri.getPort() + ""; String path = uri.getPath(); String query = uri.getQuery(); mTextView.setText("获得的数据name:" + name + "\n" + "scheme:" + scheme + "\n" + "host:" + "host:" + host + "\n" + "port:" + port + "\n" + "path:" + path + "\n" + "query:" + query); } }}

Html 代码

<html><meta charset="UTF-8"><body><h1>webToApp</h1> <!--自动加载隐藏页面跳转--><!--手动点击跳转--><input type="text" value="哈喽啊 刘安" id="inputId"><a id="linkToCart" href="#">点我打开</a></body><script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script><script type="text/javascript"> $(document).ready(function(){ //点击链接的时候调用 $("#linkToCart").click(function(){ //得到input的值 var id = $("#inputId").val(); //设置linkToCart的href的值 $("#linkToCart").attr("href","ckck://myProject.com:80/mypath?name="+id); }); });</script></html>

 

上一篇:发生系统错误 5。
下一篇:没有了
网友评论