这个google函数会在cclayers上调用,例如暂停等视图名称 analyticsInterface.cpp
void analyticsInterface::google (std::string x){
JniMethodInfo t;
if (JniHelper::getMethodInfo(t,
"com.pathto.MainActivity",
"ganalyiticscall",
"(Ljava/lang/String;I;)V;")) {
char* myName = "root view";
int times = 3;
jstring stringArg1 = t.env->NewStringUTF(myName);
t.env->CallVoidMethod(t.classID,
t.methodID,
stringArg1);
t.env->DeleteLocalRef(t.classID);
t.env->DeleteLocalRef(stringArg1);
}}
尝试通过cpp调用此函数,因为主要活动并不知道哪个图层处于活动状态。
mainacivity.java
public void ganalyiticscall(String ScreenName){
GoogleAnalytics mGaInstance = GoogleAnalytics.getInstance(this);
Tracker t = mGaInstance.newTracker("UA-xxxxx-1");
Log.i("call from ganal","tracker made");
// Set screen name.
t.setScreenName(ScreenName);
// Send a screen view.
t.send(new HitBuilders.ScreenViewBuilder().build());
}