Recently, you need to integrate WebTrends under Android in the Sencha Touch + phonegap architecture, documenting some of the processes
Check the Xia Guan Network SDK description, it seems to support in mixed mode to do something, the approximate steps are as follows,
- Add A custom to the WebViewClient WebView handle communication from JavaScript on the embedded web content to the native APPL Ication.
- Modify your custom to WebViewClient extend WebtrendsWebViewClient instead of WebViewClient .
- If you is overriding onLoadResource , call super.onLoadResource .
- Set your custom on WebViewClient your WebView .
ImportAndroid.Webkit.WebView;
ImportCom.WebTrends.Mobile.Analytics.Android.Webviewextension.Webtrendswebviewclient;
Public Class Mycustomwebviewclient Extends Webtrendswebviewclient{
@Override
public void (webview View string Url) {
super. Onloadresource (view, URL
}
}
StringUrl= "File:///android_asset/WebContent/webViewContent.html";
WebViewWv= (webview) findviewbyid ( r.. Webview1
Wv. (). Setjavascriptenabledtrue Wv. Setwebviewclient (new Mycustomwebviewclient Wv.url
- Add to the content that'll be loaded in the WebView. is delivered as part of the WebtrendsMobileLib.js WebtrendsMobileLib.js Webtrends Mobile Librar Y for Android.
- Use the to WebtrendsLib generate events. In the embedded Web content, use the JavaScript helper functions of the webtrendsLib object to generate events through the native App. A JavaScript helper function exists for each of the event helper functions exposed in the native Webtrends SDK. The JavaScript helper functions take the same arguments as the native helper functions.
<script Type="Text/javascript" Src="Js/webtrendsmobilelib.js"></script>
<script Type="Text/javascript">
functionSendbuttonclickevent() {
VarEventpath= "/helloworld/button/click";
VarEventdesc= "HelloWorld button click Event";
VarEventType= "Click";
VarCustomData= {
Customkey: "Customvalue"
};
Webtrendslib.OnButtonClick(Eventpath,Eventdesc,EventType,
CustomData);
}
</script>
<body>
<div>
<input type= " Button " onclick=" Sendbuttonclickevent () " value = "click Me" >
</input>
& nbsp </div>
</body>
</HTML>
This is the problem. After using the PhoneGap default mainactivity to inherit cordovaactivity, and if you want to integrate WebTrends, but also inherit Webtrendsactivity, under Java does not support multiple inheritance, how to do it ...
seems to be the only big move, the WEBTRENDSSDK anti-compilation,
looks like the code is not too much, put Webtrendsactivity.java inside the code copied out, paste into their new Mywebtrendsactivity.java, and then let mywebtrendsactivity inherit Cordovaactivity, Finally let mainactivity inherit mywebtrendsactivity, with the combination of methods to solve multiple inheritance, continue a toss after it works.
Another problem is that if you have your own WebClient, you also need to inherit webtrendswebviewclient, Unfortunately PhoneGap also really realized their own webviewclient, that is cordovawebviewclient, is the same problem, to modify the PhoneGap code is not realistic or scientific. What the hell?? After a tangle, find the lucky thing in the WebTrends code webtrendsdatacollector.getinstance (). Extendswebview ( WebView); As said above, WebView is a native webview, and if you have your own webview, you must inherit webtrendswebviewclient cordovawebview passed in, also can, do not have to achieve, Khan Σ (° °| | |) ︴
After these two questions, the others are fine. Note In the configuration to modify timezone and wt_dc_dcsid is necessary, wt_dc_dcsid need to take with WebTrends, estimated price is not expensive, we are customer-provided, paste directly.
The download of the SDK is also more wonderful, need to post with the administrator application to link.
Android Mobile Web Integration Webtrends