0

Initialize multiple segment instances - Android

Hi,

How do I initialize multiple instances of analytics library in android client? The context or use case is to send event data to different segment sources. 

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi OkHi - thanks for reaching out! In theory you could initialize with something along the lines of below:
      Analytics analytics1 = new Analytics.Builder(context, "key1").build();
      Analytics analytics2 = new Analytics.Builder(context, "key2").build();

    However we do not recommend this - you should only ever initialize ONE instance of the Analytics client. These are expensive to create and throw away, and in most cases, you should stick to our singleton implementation to make using the SDK easier. Further details here. For a possible alternative to send events to different sources, our Repeater destination may be worth considering.
    Best,
    James

    Reply Upvote
reply to topic