Last active
October 6, 2021 01:51
-
-
Save thanhtungka91/56e9e26f7254a4ba62fb8078e1afb73e to your computer and use it in GitHub Desktop.
TWA start a new activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected CustomTabsSession getSession(CustomTabsClient client) { | |
return client.newSession((CustomTabsCallback) null, 96375); | |
} | |
public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) { | |
CustomTabsSession mSession = MainActivity.this.getSession(client); | |
if (mSession == null) { | |
Toast.makeText(MainActivity.this, | |
"Couldn't get session from provider.", Toast.LENGTH_LONG).show(); | |
} | |
Uri url = MainActivity.this.getLaunchingUrl(); | |
// custom url for notification | |
if (appLink != null) { | |
String applinkString = appLink.toString(); | |
// add sub router android to uri | |
url = Uri.parse(applinkString); | |
} | |
Log.d("TWALink", url.toString()); | |
TrustedWebActivityIntentBuilder builder = new TrustedWebActivityIntentBuilder( | |
url); | |
Intent intent = builder.build(mSession).getIntent(); | |
MainActivity.this.startActivity(intent); | |
MainActivity.this.mTwaWasLaunched = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment