CustomTabs activity destroys starter actvity

Viewed 79

I'm trying to use the custom tabs activity to let the user do a small navigation within my app.

The intent filter is ok, the starter activity is ok, the browser is okay. but the browsertab is created automatically my activity get destroyed and i lose all its state.

why? here is the code

@Override
    protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        this.caller = savedInstanceState.getString("caller", null);
    }

    @Override
    protected void onSaveInstanceState(@NonNull Bundle outState) {
        outState.putString("caller", this.caller);
        super.onSaveInstanceState(outState);
    }
    
       
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        if (getIntent().getBooleanExtra("starting", false)) {
            this.caller = getIntent().getStringExtra("caller"); //THIS IS ALWAYS != NULL, i've debugged and check

            Intent intent = new CustomTabsIntent.Builder().setUrlBarHidingEnabled(true).setShowTitle(false).build().intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY).setData(Uri.parse(URL_BUILDER.buildLoginUrl()));
            PendingIntent pi = PendingIntent.getActivity(this, 123, intent, PendingIntent.FLAG_IMMUTABLE);

            if (hasChrome())
                intent.setPackage("com.android.chrome");

            this.customTabLauncher.launch(new IntentSenderRequest.Builder(pi).setFillInIntent(intent).build());
        } else Sytem.out.println(this.caller);

}

here is what happen, from some activity, i start this activity above passing the "starting" and "caller" fields in the intent, this works fine i've already debugged and checked... but without I call finish anywhere, this activity gets closed then i lose all its info for the return of customtabs

in my manifest i've

<activity
            android:name="com.tomatedigital.androidutils.CustomTab"
            android:exported="true"

            tools:node="merge">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="cct.face.otarios"
                    android:scheme="test" />
            </intent-filter>
        </activity>

what am my missing? in the debug session i've seen the onSaveInstanceState being called, but the restore never is.

0 Answers
Related