zoukankan      html  css  js  c++  java
  • Android JS打开原生应用

    设置App通过网页JS,唤醒打开本地应用.

    在AndroidManifest 中,在应用启动页配置下,添加android:exported="true",设置category 添加data

    示例:

    当配置应用的跳转协议为:

    demo://?param1=参数1&param2=参数二

    当手机访问该协议时,我们应用如何设置可以被唤醒呢?

     

       <activity
    android:name
    =".StartActivity" android:exported="true"> <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"></action> <category android:name="android.intent.category.DEFAULT"></category> <category android:name="android.intent.category.BROWSABLE"></category> //协议头部 <data android:scheme="demo"/> </intent-filter> </activity>


    //我们怎样在StartActivity 中获取传过来的参数
     Intent inten=getIntent();
              Uri uri=intent.getData();           //获取跳转的协议
               if(uri!=null)                                   //跳转协会为空,说明应用是正常启动
              {
                      String param1=uri.getQueryParameter("param1");
                      String param2="uri".getQueryParameter("param2");
                 }
    //总结:对协议的书写要求比较高,一定要注意大小写,和规则规范,和前端调用保持一致


  • 相关阅读:
    Femap和NX Nastran简介 / Introduction of Femap and NX Nastran
    WINDOWS蓝屏错误对照表[z]
    Matlab 样条工具箱(Spline ToolBox)[z]
    NumPy 简介
    NX Nastran[z]
    UG后处理实例讲解
    NumPy for Matlab Users【z】
    PyMat An interface between Python and MATLAB
    ANSYS Workbench Products Installation and Configuration Guide
    NumPy使用手记[z]
  • 原文地址:https://www.cnblogs.com/changeMsBlog/p/9902227.html
Copyright © 2011-2022 走看看