Android Mobile Web Integration Webtrends

Source: Internet
Author: User

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,

   

  1. Add A custom to the WebViewClient WebView handle communication from JavaScript on the embedded web content to the native APPL Ication.
    • For a basic implementation, use theextendsWebViewHelper method in theWebtrendsDataCollectorTo add the Webtrends customWebViewClient:
      StringUrl= "File:///android_asset/WebContent/webViewContent.html";
      WebViewWv= (WebViewfindviewbyid (r.< Span class= "PLN" >id.
      Wv. (). Setjavascriptenabledtrue webtrendsdatacollector. Getinstance (). Extendswebviewwv      
      Wv. Loadurlurl
    • If your application uses its own custom webviewclient, you should don't use the extendsWebView helper method. Instead, ensure that's WebtrendsWebViewClient also gets invoked by following these steps:
    1. Modify your custom to WebViewClient extend WebtrendsWebViewClient instead of WebViewClient .
    2. If you is overriding onLoadResource , call super.onLoadResource .
    3. 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
  2. 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.
  3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.