简体   繁体   English

受信任的 web 活动中的主要活动

[英]Main activity inside trusted web activity

I started to use Trusted Web Activiy and everything is fine.我开始使用Trusted Web Activiy ,一切都很好。

Now I want to install Push Notification library and my push ntification service provider needs to add a block of code in MAIN ACTIVITY .现在我想安装Push Notification库,我的推送通知服务提供商需要在MAIN ACTIVITY中添加一段代码。

From other hand, I need some check before user start visiting my website like:另一方面,在用户开始访问我的网站之前,我需要进行一些检查,例如:

  1. Does She/He have an Interet Connection她/他是否有互联网连接
  2. Is Her/Him google chrome up to date她/他的谷歌浏览器是最新的吗
  3. Get Her/Him device Id获取她/他的设备 ID
  4. and etc...等等...

So, I need manuplate a splash screen and Main Activity , but I don't know where is main activity to do stuff as I'm newbie to this.所以,我需要制作一个启动画面和Main Activity ,但我不知道主要活动在哪里做事情,因为我是新手。

Would you please let me know how should I solve this issues?请让我知道我应该如何解决这个问题?

Thanks in Advance提前致谢

You can add a new activity, say MainActivity, which will start at application startup instead of TWA activity and do any additional processing in it's onCreate() method.您可以添加一个新活动,比如 MainActivity,它将在应用程序启动时而不是 TWA 活动开始,并在它的 onCreate() 方法中进行任何额外的处理。 In the end of onCreate() method you can activate your TWA activity with the intent like this:在 onCreate() 方法结束时,您可以使用以下意图激活 TWA 活动:

startActivity(new Intent(this, com.google.androidbrowserhelper.trusted.LauncherActivity.class));

To make MainActivity the one which opens at application start you will have to remove intent filter from your TWA activity in AndroidManifest.xml and place it into your MainActivity:要使 MainActivity 在应用程序启动时打开,您必须从 AndroidManifest.xml 中的 TWA 活动中删除意图过滤器并将其放入 MainActivity:

<activity android:name=".java.MainActivity" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Some more details in this post: https://stackoverflow.com/a/58069713/8818281这篇文章中的更多细节: https://stackoverflow.com/a/58069713/8818281

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM