Home » Android » android – The method setLocalDispatchPeriod(int) from the type GAServiceManager is deprecated

android – The method setLocalDispatchPeriod(int) from the type GAServiceManager is deprecated

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have latest Google analytics SDK for android and seems like setLocalDispatchPeriod(int) has been deprecated. What is the fix for this ?

There is no where in the internet I could find alternate method for this. And most funniest thing is, google has used this method in their own tutorial of how to get started.

Now does does anybody knows any alternate method ?

How to&Answers:

The reason for the deprecation is outlined in the ServiceManager JavaDoc:

This only works if local dispatching is in use. Local dispatching is
only used in the absence of Google Play Services on the device or if
manually forced (see setForceLocalDispatch()). In general,
applications can not rely on the ability to set the dispatch period.
This method should therefore be used with some discretion.

If you are using EasyTracker, you can also specify ga_dispatchPeriod in your analytics.xml file, which should not throw a lint warning about deprecation.

<resources>
  <string name="ga_trackingId">UA-XXXXXXXX-X</string>

  <integer name="ga_dispatchPeriod">30</integer>

  <!-- [...] -->
</resources>

See the Dispatching page of the docs.