Get CustomTabsSession from Bubblewrap generated TWA
05:43 23 Nov 2022

I create a TWA using Bubblewrap and the app works fine. Now I need to send a WebMessage and this can be done with CustomTabs, according to the documentation, but I don't know how to get the active CustomTabsSession object from any of these classes to work with it

AndroidManifest.xml:



    

        


            


        
            
            
            


        
            

            

            

            

            

            

            

            

            

            

            

            




            


            





            
                
                
            

            
                
                
                
                
            


        

        

        

        
            
        

        


                


            
                
                
            
        


            

    


LauncherActivity.java:

import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

public class LauncherActivity
        extends com.google.androidbrowserhelper.trusted.LauncherActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        }
    }

    @Override
    protected Uri getLaunchingUrl() {
        // Get the original launch Url.
        Uri uri = super.getLaunchingUrl();

        return uri;
    }
}

Application.java:

public class Application extends android.app.Application {

  @Override
  public void onCreate() {
      super.onCreate();
  }
}
android chrome-custom-tabs trusted-web-activity bubblewrap