I have integrated Trusted Web Activity in my android app, when launching TwaLauncherActivity as main Activity, a blank white screen is displaying. I have followed, below GitHub link. https://github.com/GoogleChrome/custom-tabs-client/tree/master/svgomg. Please suggest some solution, thanks in advance,
TwaLauncherActivity.java
package com.therightdoctors.dpmdoctor;
import android.net.Uri;
import android.os.Bundle;
import android.support.customtabs.CustomTabsIntent;
import android.support.v7.app.AppCompatActivity;
public class TwaLauncherActivity extends AppCompatActivity
implements TwaSessionHelper.TwaSessionCallback {
private static final String TWA_ORIGIN = "https://dpm.therightdoctors.com";
private static final String TARGET_URL = TWA_ORIGIN;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_twa_launcher);
Uri originUri = Uri.parse(TWA_ORIGIN);
TwaSessionHelper twaSessionHelper = TwaSessionHelper.getInstance();
twaSessionHelper.setTwaSessionCallback(this);
twaSessionHelper.bindService(this, originUri);
/* TwaSessionHelper.TwaSessionCallback twaSessionCallback = twaSessionHelper.mTwaSessionCallback.get();
if (twaSessionCallback != null) twaSessionCallback.onTwaSessionReady();*/
// Set an empty transition from TwaLauncherActivity to the splash screen.
CustomTabsIntent customTabsIntent = twaSessionHelper.createIntentBuilder()
.setStartAnimations(this, 0, 0)
.build();
Uri openUri = Uri.parse(TARGET_URL);
twaSessionHelper.openTwa(this, customTabsIntent, openUri);
}
@Override
protected void onDestroy() {
super.onDestroy();
TwaSessionHelper twaSessionHelper = TwaSessionHelper.getInstance();
twaSessionHelper.setTwaSessionCallback(null);
}
public void openTwa() {
TwaSessionHelper twaSessionHelper = TwaSessionHelper.getInstance();
// Set an empty transition from TwaLauncherActivity to the TWA splash screen.
CustomTabsIntent customTabsIntent = twaSessionHelper.createIntentBuilder()
.setStartAnimations(this, 0, 0)
.build();
Uri openUri = Uri.parse(TARGET_URL);
twaSessionHelper.openTwa(this, customTabsIntent, openUri);
}
@Override
public void onTwaSessionReady() {
openTwa();
}
@Override
public void onTwaSessionDestroyed() {
}
@Override
public void onTwaOpened() {
/*finishAndRemoveTask();*/
}
}
Debug catalog is showing below exception,
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.therightdoctors.dpmdoctor/com.therightdoctors.dpmdoctor.TwaLauncherActivity}: java.lang.IllegalArgumentException: Given CustomTabsIntent should be associated with a valid CustomTabsSession at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
Aucun commentaire:
Enregistrer un commentaire