Add openxlive data analysis to Windows Phone applications

Source: Internet
Author: User

Author: Ma Ning

Source code:

Http://files.cnblogs.com/aawolf/OpenXLiveAnalytics.zip

In Windows Phone, many applications require the data query function to determine the number of users per day and the number of Application Usage and other key information. There are already many similar applications in iOS and Android, such as flurry and umeng. However, only flurry provides such functions on Windows Phone. However, for many developers, the lack of Chinese support for flurry is a little daunting.

In fact, openxlive also provides data analysis support, but it was previously used for statistics and query of game data. In this articleArticleWe will introduce how to apply the data analysis function of openxlive to Windows Phone.ProgramUnder development.

Create an openxlive Application

Because all the statistics are stored in the openxlive cloud storage server, we need to create an application on the openxlive website.

First, log on to the openxlive website (http://www.openxlive.com/), if there is no account, we need to create a corresponding account, after activating the account through email, we also need to upgrade to become a developer.

After activating the email address, we will return to the openxlive website. after entering the user name and password, we will enter the user information editing page. Here, we can fill in the complete personal information, it makes it easier for friends to find you on the Internet. The last item in the user information is "developer information ".

Click "developer information" to go to the developer application page:

On this page, you must enter the developer type (Personal/Company/student), country, city, address, phone number, Im, and other information. After entering this information, we will see the following developer registration success page.

On this page, you can go to the openxlive developer homepage, view the development guide, or click "Create New Game" to go to the developer background.

After entering the developer background interface, if you have already created a game, a list of created games is displayed, as shown in. Under the user icon, click the create new game button to go to the page for creating a new game.

Add openxlive reference

To reference the openxlive Assembly, we must first download the openxlive SDK and complete the installation. Yes: The current http://developer.openxlive.com/sdk/download/ version is 0.9.6.

After creating the Windows Phone Silverlight application, we need to obtain the openxlive assembly. In the Start Menu, find the openxlive application. The openxlive directory contains the xNa and Silverlight directories. We extract the openxlive. dll Assembly from the Silverlight directory and copy it to the directory where our application is located.

In Solution Explorer, right-click references and choose add reference. In the dialog box, select the Browse page, find openxlive. dll, and add it to the project.

Because we do not need the openxlive interface, we only need to add openxlive. dll.

After adding a reference, we can addCode.

Create a session

Next, we will add the reference code of openxlive for the project. Open the app. XAML. CS file in the project, first find the application_launching method:

 
Private VoidApplication_launching (ObjectSender, launchingeventargs e ){If(Xlivegamemanager. currentsession =Null) {Gamesession session = xlivegamemanager. createsession ("XXXXXXXX"); Session. createsessioncompleted + =NewAsynceventhandler (session_createsessioncompleted); Session. open ();}}

In this method, we can determine whether a game session already exists. If not, we will call the createsession method of xlivegamemanager to create a game session. The parameter to be passed, is the secret key we obtained on the openxlive website.

Then, we can add a createsessioncompleted event processing function to obtain whether the game session is created. Of course, this event handler function is optional and can be left empty.

Finally, call the open method of the game session to open the game session.

Close the game session and call the close method in the application_closing method.

 
Private VoidApplication_closing (ObjectSender, closingeventargs e ){If(Xlivegamemanager. currentsession! =Null) {Xlivegamemanager. currentsession. Close ();}}

If we do not explicitly call the close method, the game session will automatically expire 24 hours after it is created, so it will not cause too much impact. The only problem is that the game time will be invalid.

To support the tombstone mechanism, we also need to add the processing of the tombstone mechanism to the application_activated and application_deactivated functions.

 

  private   void  application_activated ( Object  sender, activatedeventargs e) {xlivegamemanager. activated ();}  private   void  application_deactivated ( Object  sender, deactivatedeventargs e) {xlivegamemanager. deactivated () ;}

 

Well, here we are all done. Is it easy enough?

View data results

After the Windows Phone software is released, you can view the online data of the application on the openxlive website.

First, we visit the openxlive website http://www.openxlive.com/, click Login login in the upper right corner of the page, after successful login, we will see the following page in the upper right corner of the openxlive Home Page:

Click my game to go to the dashboard of game background management. If you log on to the openxlive developer website (http://developer.openxlive.com/), select "managed your games" in the dashboard on the right to enter the developer background management interface.

Shows all the games and applications we have created. Click the application icon to go to the application industry page. Click the application title to go to the application management interface.

Click the statistics button on the Management page to go to the Data Analysis page.

On the Data Analysis page, we can view some common information, such as the number of sessions created and the number of users. Click View to go to the detailed data analysis page.

In the detailed data analysis interface, we can test the time distribution of the number of users and sessions, and display them by month, week, or day.

Conclusion

Now, we will introduce the current data analysis function of openxlive. In the next step, openxlive will also add features such as custom events and geographical distribution information.

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.