Giter Club home page Giter Club logo

Comments (4)

cqr avatar cqr commented on August 28, 2024

Actually, it looks like onActivityResult is passed to fragments (who knew?) so your base activity could actually be very little.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHelper = GameHelper.attach(this, <optional flags for clients here>);
}

// methods that wrap mHelper in a warm, loving embrace.

from android-basic-samples.

btco avatar btco commented on August 28, 2024

Good idea. We'll look into it.

from android-basic-samples.

yhuiyang avatar yhuiyang commented on August 28, 2024

Hi @chrisrhoden
This is real cool idea, I have tried it, and it works well. But I can not omit calling mHelper.onActvityResult() in my container activity. Can you show me what you did, so you can omit calling helper's onActivityResult() explicitly in container activity?

What I did is: (similar to your first comment)
In container activity:

@override
public void onCreate(Bundle savedInstanceState) {
    ...
    mHelper = (ApiHelper) getSupportFragmentManager().findFragmentByTag(TAG_API_HELPER);
    if (mHelper == null) {
        Bundle args = new Bundle();
        args.putInt(RC_RESOLVE_SIGNIN, 9999); /* tell helper to use which request code number to resolve sign in error */
        args.putXXX(...) /* any other thing, ex: flag for different clients */
        mHelper = (ApiHelper) Fragment.instantiate(this, ApiHelper.class.getName(), args);
        getSupportFragmentManager().beginTransaction().add(mHelper, TAG_API_HELPER).commit();
    }
}
@override
public void onActivityResult(int request, int result, Intent data) {
    super.onActiivtyResult(request, result, data);
    if (request == 9999)
        mHelper.onActvityResult(request, result, data);
}

In helper

@override
public void onConnectionFailed(ConnectResult result) {
    ...
    if (result.hasResolution()) {
        Bundle args = this.getArguments();
        int rc = args.getInt(RC_RESOLVE_SIGNIN);
        result.startResolutionForResult(getActivity(), rc); /* The first parameter needs activity, I can not use fragment here. So, I think currently the resolution activity is started from container activity instead of fragment itself */
    }
}

from android-basic-samples.

samtstern avatar samtstern commented on August 28, 2024

Closing due to the samples no longer using BaseGameActivity/GameHelper. See this video for more information.

from android-basic-samples.

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.