Dhanaji Yadav
Dhanaji Yadav

Reputation: 1422

Trusted Web Activity : TwaLauncher onDestroy() does not work

I want to close the Trusted web activity tab programmatically. I am trying the onDestroy method from twaLauncher but it does not work.

        twaLauncher = new TwaLauncher(activity);
        twaLauncher.launch( new TrustedWebActivityIntentBuilder(uri), null, null, null);

        final Handler handler = new Handler(Looper.getMainLooper());

        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                twaLauncher.destroy();
                Toast.makeText(activity, " twaLauncher.destroy() called", Toast.LENGTH_LONG).show();
            }
        }, 5000);

Upvotes: 0

Views: 465

Answers (1)

andreban
andreban

Reputation: 4976

The Trusted Web Activity itself runs inside Chrome, that is, a different application than the one running TWALauncher. It's currently impossible to programmatically close it from the launcher app. The web page should be able to close it via window.close() (I haven't tested that, though).

Upvotes: 1

Related Questions