Android Question Google Analytics getTracker how?

navicula

Member
Licensed User
Longtime User
When I use this lines for Google Analytics, I get this error: Error occurred
An error has occurred in sub: java.lang.NoSuchMethodException: getTracker()

B4X:
Dim r As Reflector
r.Target = r.RunStaticMethod("com.google.analytics.tracking.android.EasyTracker", "getTracker", Null, Null)
r.RunMethod2("sendView", "<pnlChartContains>", "java.lang.String")

Why is it?
 

navicula

Member
Licensed User
Longtime User
What does sendview do?
I would like to „Manual Screen Measurement”(https://developers.google.com/analytics/devguides/collection/android/v3/screens).
How is it in b4a? The google write this: To get the most complete screen view data, add the EasyTracker methods to all of the Activities in your app.”
B4X:
public class myTrackedActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Override
  public void onStart() {
    super.onStart();
    ... // The rest of your onStart() code.
    EasyTracker.getInstance(this).activityStart(this);  // Add this method.
  }

  @Override
  public void onStop() {
    super.onStop();
    ... // The rest of your onStop() code.
    EasyTracker.getInstance(this).activityStop(this);  // Add this method.
  }
}
And this:
B4X:
// May return null if EasyTracker has not yet been initialized with a property
// ID.
Tracker easyTracker = EasyTracker.getInstance(this);

// This screen name value will remain set on the tracker and sent with
// hits until it is set to a new value or to null.
easyTracker.set(Fields.SCREEN_NAME, "Home Screen");

easyTracker.send(MapBuilder
    .createAppView()
    .build()
);
Thank you for your help!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…