Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error not wroking with fragmentActivity #57

Open
piyushshende76 opened this issue Aug 20, 2020 · 3 comments
Open

error not wroking with fragmentActivity #57

piyushshende76 opened this issue Aug 20, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@piyushshende76
Copy link

as i extends my mainactivity with fragment activity

error lies in
mUpdateManager = UpdateManager.Builder(this);

this only suport appcompact activity

please tell how to solve this error

@piyushshende76 piyushshende76 added the bug Something isn't working label Aug 20, 2020
@SanojPunchihewa
Copy link
Owner

SanojPunchihewa commented Aug 21, 2020

Currently, this wrapper library only supports AppCompactActivity only. If you need to use FragmentActivity please check the original implementations at the official site

It would be great if you can add that feature to this library as well

@cmy82
Copy link

cmy82 commented Feb 24, 2021

You can change the constructor to this:

private UpdateManager(Context context) throws Exception {
        mActivityWeakReference = new WeakReference<>(context);
        this.appUpdateManager = AppUpdateManagerFactory.create(context);
        this.appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();
        if(context instanceof AppCompatActivity){
            ((AppCompatActivity)context).getLifecycle().addObserver(this);
        } 
        else if(context instanceof FragmentActivity){
            ((FragmentActivity)context).getLifecycle().addObserver(this);
        }
        else throw new Exception("Use of this  library requires attaching to a FragmentActivity or AppCompatActivity.");
    }

@SanojPunchihewa
Copy link
Owner

Hi @cmy82 , really value your contribution. But I'm quite busy these days. It will be great if you can send a PR for the above feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants