从受信任的Web活动(TWA)启动另一个活动 [英] Launching another activity from a Trusted Web Activity (TWA)

查看:76
本文介绍了从受信任的Web活动(TWA)启动另一个活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试通过意图URI从TWA启动另一个活动时遇到问题."intent://#Intent; scheme = subscriptionschemetwa; package = com.package.www.twa; end" 当然,程序包名称在现实中是唯一的.

I have problems trying to launch another activity from the TWA via the intent URI. "intent://#Intent;scheme=subscriptionschemetwa;package=com.package.www.twa;end" The package name is unique in reality, of course.

我和他们一起玩耍,向URI添加了主机,动作,其他内容,但没有任何效果.

I've played around with them, added host, action, extras etc. to URI, but nothing had an effect.

由于我是本机开发的新手,所以希望获得一些帮助.该应用程序本身尚未在Google Play上公开发布(仅限内部使用),它已与Bubblewrap签名并打包在一起,并通过adb安装.意图URI的后备确实可以将我带到商店的内部列表,但是我不知道为什么活动没有开始.

As I'm new to native development, I'd appreciate some help. The app itself is not publicly available on Google Play yet (only internally), it's signed and packaged with Bubblewrap, and installed via adb. The intent URI's fallback does work in the sense it takes me to the Store's internal listing, but I have no idea why the activity is not started.

XML块:

        <activity android:name="SubscriptionActivity">
            <intent-filter>
                <data
                    android:host="com.package.www.twa"
                    android:scheme="subscriptionschemetwa" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>
        </activity>

Activity与批量创建相同,只是添加了一个日志以检查其是否输入了该方法.不会.

The Activity is the same from bulk create, with an added log just to check if it ever enters the method. It does not.

class SubscriptionActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        println("------test------")
        setContentView(R.layout.activity_subscription)
    }
}

单击指向意图URI的链接后,logcat日志似乎表明根本没有尝试启动活动,而是直接进入商店.我可以直接通过adb shell运行该活动.

The logcat logs after clicking on the link pointing to the intent URI seem to show there is no attempt to start the activity at all, rather it goes directly to the store. I can run the activity directly through the adb shell just fine.

09-11 20:57:30.419  1595 25814 I CLP     : startActivity sender check.  com.android.chrome to Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=market://details?id=com.package.www.twa&referrer=com.android.chrome flg=0x10000000 pkg=com.android.vending cmp=com.android.vending/com.google.android.finsky.activities.MarketDeepLinkHandlerActivity (has extras) }
09-11 20:57:30.607  9562  9804 I AppIconSolution: load=com.package.www.twa, bg=96-96, dr=132-132, forDefault=false, density=0
09-11 20:57:30.611  9562  9804 I AppIconSolution: load=com.package.www.twa-theme2, bg=96-96, dr=132-132, tarScale=0.65, relScale=0.48, mask=false
09-11 20:57:30.786 22165 22165 I Finsky  : [2] hze.a(11): Selecting account [xxxxxxxxxxxxxxxxxxxxxxxxxx] for package com.package.www.twa. overriding=[true]
09-11 20:57:30.794 22165 22165 I Finsky  : [2] hze.a(11): Selecting account [xxxxxxxxxxxxxxxxxxxxxxxxxx] for package com.package.www.twa. overriding=[true]
09-11 20:57:30.917 22165 22200 I Finsky  : [842] lge.run(418): Dropped referrer for com.package.www.twa because dropped_already_installed
09-11 20:57:30.934 22165 22165 I Finsky  : [2] hze.a(11): Selecting account [xxxxxxxxxxxxxxxxxxxxxxxxxx] for package com.package.www.twa. overriding=[true]
09-11 20:57:30.940 22165 22165 I Finsky  : [2] hze.a(11): Selecting account [xxxxxxxxxxxxxxxxxxxxxxxxxx] for package com.package.www.twa. overriding=[true]

任何输入都会受到赞赏,我已经参加了好几天了,但我实在无法忍受.

Any input is appreciated, I've been on this for days now and I just can't wrap my head around it.

推荐答案

因此,意图URI似乎是错误的.实际上,我使用我认为是不建议使用的通过意图URI调用活动的方法来成功地开始了活动.但是,嘿,它有效.我最终使用的URI是:

So it seems that the intent URI was wrong. I actually managed to start the activity without issues using what I thought was a deprecated way to invoke activities via intent URIs. But hey, it works. The URI I ended up using was:

subscriptionschemetwa://www.package.com

或更笼统地说

scheme://host

希望它可以帮助某人避免像我一样浪费时间:D

Hope it helps someone avoid wasting time like I did :D

这篇关于从受信任的Web活动(TWA)启动另一个活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆