简体   繁体   中英

Main activity inside trusted web activity

I started to use Trusted Web Activiy and everything is fine.

Now I want to install Push Notification library and my push ntification service provider needs to add a block of code in 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
  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.

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. In the end of onCreate() method you can activate your TWA activity with the intent like this:

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:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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