美文网首页
浏览器打开android app

浏览器打开android app

作者: 络雨凉 | 来源:发表于2021-11-09 17:12 被阅读0次

    html

    <a href="[scheme]://[host]/[path]?[query]">启动应用程序</a>
    

    android

    1. manifest
    <activity android:name="com.ttj.v2pro.ui.TestActivity"
                android:launchMode="singleTask">
    
                <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" />
                    <data android:scheme="ttj" android:host="splash" />
                </intent-filter>
    
    </activity>
    
    1. activity
        override fun onNewIntent(intent: Intent?)
        {
            super.onNewIntent(intent)
    
            if (intent != null && intent.action == Intent.ACTION_VIEW)
            {
                val uri = intent.data
                if (uri != null)
                {
                    val name = uri.getQueryParameter("name")
                    toast("onNewIntent:" + name)
                }
            }
        }
    

    相关文章

      网友评论

          本文标题:浏览器打开android app

          本文链接:https://www.haomeiwen.com/subject/waxvzltx.html