Android WeChat sharing

Source: Internet
Author: User

Android sharing

To add the shared feature to the Android app, follow these steps:

 

 

 

3. Introduce the user push project library (Download user push social sharing components: http://youtui.mobi/download/index.htm)

Place the youtui-lib project library and application project in the same directory, right-click the project root directory in Package Explorer, select Properties, and click, click Add in the Android option to Add youtui-lib */

4. Register a Sharing Platform

1. Configure the key of each sharing platform. The configuration file is youtui_sdk.xml, which is placed in the assets folder of the project.

2. if you want to share it with a platform, set the Enable attribute of the platform to true. 3. to arrange a platform to the front, you only need to change its position in the youtui_sdk.xml file. */ 5. Register permissions/* Register permissions in AndroidManifest. xml */ 6. register the required Activity in AndroidManifest. xml.

7. Callback settings with the circle of friends

You need to create an application package name +. wxapi package, under which WXEntryActivity is created. java: inherits this class from cn. bidaround. youtui. wxapi. WXEntryActivity (no code is needed) */publicclassWXEntryActivityextendscn. bidaround. youtui. wxapi. WXEntryActivity {}

8. Initialization

The program starts. It is best to call YtTemplate in the onCreate method of MainActivity. init (this) indicates the initialization of the sdk, so that the sdk can be called subsequently (otherwise, a null pointer exception occurs during sharing and other operations), for example: */protectedvoidonCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); YtTemplate. init (this);/* initialization friend push */initView ();}/* When the application exits: insert the following code YtTemplate In the first line of the onDestroy method of the exit Activity of your project. release (this); this method is used to release memory and collect statistics on user usage. Once release is called, you must call init again to enable UF to push Otherwise, a null pointer exception occurs. */9 when you create an external data instance, call the set Method of the instance to set the data you want to share. For details about the instance, see the following section, if you only want to share an application, you only need to set setIsAppShare (true) to share the information and download link entered by the application in the user push background. Fields contained in external data: isAppShare text imagePath imageUrl description title target_url/* determines whether the text to be shared by the sharing application is used. The text message length is less than 70 characters, and the microblog length is less than 140 characters, if you want to share a link, you 'd better put the link url at the address of the local image to be shared. If you want to share an image, select one from the local image and the network image, if both images are available, the URLs of the images to be shared are prioritized. If you want to share images, select one of the local and network images, if any, the system first shares the description of the content to be shared in the local image. The title of the content to be shared is a jump link to the content to be shared */call the set Method of the instance to set these parameters by creating the instance, for example, export data into data = newdomaindata (); then data. isAppShare = false;/* if it is set to true, the shared information is read from the application information filled in by the user push background, which can be dynamically updated. You do not need to set the value. */Collect data. setDescription (the upstreaming point component); collect data. setTitle (share with friends); collect data. setText, developers can also integrate the points function independently on the existing sharing components of the app, come and try it http://youtui.mobi); collect data. setTarget_url (http://youtui.mobi); fetch data. setImageUrl (http://youtui.mobi/media/image/youtui.png); your data. setImagePath (http://cdnup.b0.upaiyun.com/media/image/default.png); 9. call a friend to share the recommendation component
PublicvoidonClick (View v) {if (v. getId () = R. id. popup_bt) {/* call the sharing recommendation component. The constant of the YouTuiViewType class is the sharing style parameter. Currently, the sharing template can be created in two formats: White List and black mesh, the first parameter is activity, the second parameter is share window style, and the third parameter is whether credits */YtTemplate blackTemp = newYtTemplate (this, YouTuiViewType. BLACK_POPUP, false); // The black mesh style does not require point activity/* YtTemplate blackTemp = new YtTemplate (this, YouTuiViewType. WHITE_LIST, ture); * // the White List style requires the integral activity primary data = new1_data (); lateral dat A. isAppShare = false; // if this parameter is set to true, the shared information is read from the application information filled in by the user push background. You do not need to set the value after dynamic updates. Invalid Data. setDescription (the upstreaming point component); collect data. setTitle (share with friends); collect data. setText, developers can also integrate the points function independently on the existing sharing components of the app, come and try it http://youtui.mobi); collect data. setTarget_url (http://youtui.mobi); fetch data. setImageUrl (http://youtui.mobi/media/image/youtui.png); your data. setImagePath (http://cdnup.b0.upaiyun.com/media/image/default.png); blackTemp. setmediadata (ShareData); // set the default share data; for setting external data, see 4.6 // ** if you want to set different share information for a platform. Set * // blackTemp separately. addData (YtPlatform. PLATFORM_QQ, shareData); // bring up the sharing window blackTemp. show (); // If You Need to customize the sharing event, you can create a listening event and process the YtShareListener listener1 = newYtShareListener () {@ Override publicvoidonSuccess (ErrorInfo arg0) in the callback) {}@ Override publicvoidonPreShare () {}@ Override publicvoidonError (ErrorInfo arg0) {}@ Override publicvoidonCancel () {}}; // Add the sharing listener blackTemp to Sina Weibo. addListener (YtPlatform. PLATFORM_SINAWEIBO, listener1); // Add a sharing listener to QQ. // blackTemp. addListener (YtPlatform. PLATFORM_QQ, listener2 );}}






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.