java - Creating GoogleApiClient for multiple activities -


i developing android app google+ api. having multiple activities each require 1 instance of googleapiclient.

as understand this post possible call same instance of googleapiclient each activity. question how create copies of googleapiclient specifically?

do build 1 again .addapi(), .addscope() , implement onconnected method , onconnectedfailedlistener method again? because seems repetitive , inefficient. , wouldn't implementing these methods override same methods other activities too?

it's not expensive create multiple instances of googleapiclient. in fact efficiency if use more 1 api. services request spooled up. if 1 activity uses plus , uses drive, plus service doesn't have spooled when you're on drive activity.

to clear, recommended create separate instance of googleapiclient each activity, fragment, loader, service, or application create (maybe others forgot too).

if don't want that, use application context instead of activity or fragment create googleapiclient , hold reference in application object.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -