Reputation: 1422
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
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