GithubHelp home page GithubHelp logo

Comments (3)

SayedElabady avatar SayedElabady commented on June 9, 2024

Hey, so if I understand this correctly you need a way to add extra parameters to the intent before restarting the app?

from android-browser-helper.

SergeyPoznyakAkvelon avatar SergeyPoznyakAkvelon commented on June 9, 2024

@SayedElabady More like disable the default behavior of forwarding the intent to custom tabs activity if the app is already open. Because when it does that it doesn't let my custom activity to start and do its thing.

from android-browser-helper.

SayedElabady avatar SayedElabady commented on June 9, 2024

@SergeyPoznyakAkvelon , We can add a method to let you add extra parameters to the intent before firing it, you can find a sample below. Please let me know if this will help you in resolving the issue or not.

private boolean restartInNewTask() {
        boolean hasNewTask = (getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) != 0;
        boolean hasNewDocument = (getIntent().getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0;

        if (hasNewTask && !hasNewDocument) return false;

        //...

        Intent newIntent = new Intent(getIntent());

        int flags = getIntent().getFlags();
        flags |= Intent.FLAG_ACTIVITY_NEW_TASK;
        flags &= ~Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        newIntent.setFlags(flags);
        modifyIntentForNewTask(newIntent);
        
        startActivity(newIntent);
        return true;
    }

    /**
     * Override this method to add extra parameter to the intent before firing it when
     * restartNewTask is required.
     */
    public Intent modifyIntentForNewTask(Intent initialIntent){
        // Do the modification here as you want, for example
        //  if (shouldRestartBrowser()){
        //     add the extra parameters here, like:
        //     initialIntent.putExtra(INTENT_REFRESHED, true);
        //  }
        return initialIntent;
    }

from android-browser-helper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.