Is it a problem calling AppCenter.Start multiple times

I use AppCenter and have added

the Start() call inside the OnCreate() method in MainActivity.cs like described here:

https://docs.microsoft.com/en-us/appcenter/sdk/getting-started/xamarin

I issue that the app can be started as a service and need to call Start() in the service. In this cases it can happen that that Start() is called twice.

Is this a problem?

Best Answer

Answers

  • YorkGoYorkGo CNMember, Xamarin Team Xamurai
    edited December 2018

    I issue that the app can be started as a service and need to call Start() in the service

    Did you execute AppCenter.Start() in your service? You start the Service in your MainActivity's OnCreate() method?

    In this cases it can happen that that Start() is called twice.

    AppCenter.Start() be called twice? Could you please post the complete code? On the other hand, it use single instance, start multiple times won't do much impact on performance.

  • I call it in
    MainActivity's OnCreate()

    but it the service can start without MainActivity in some cases (intended)

    So in some cases
    AppCenter.Start()
    would be called twice if I don't handle this.

    The question is if it is any problem calling it twice?

  • JoergenStorlieJoergenStorlie US ✭✭
    edited December 2018

    In the source code I found this comment:

    • Configure the SDK with the list of services to start with an app secret parameter.
      • This may be called only once per application process lifetime.

    I must check if Start is already is called, but how?

Sign In or Register to comment.