The method of realizing micro-credit sharing information with Android programming _android

Source: Internet
Author: User

This article illustrates the method of implementing micro-credit sharing information by Android programming. Share to everyone for your reference, specific as follows:

As the micro-letters become more and more hot, more and more applications require the ability to share the micro-letters. Although there are many platforms to help integrate the sharing function, such as the League of Friends. But personally feel that the alliance is too much integration, their encapsulation too, a lot of resource files to bring in, so the feeling is not how good, so I also studied the micro-letter call its SDK to share. Let's talk about the steps below.

First: Download the official SDK demo.

Download Address: Http://open.weixin.qq.com/download/?lang=zh_CN

Second: Unzip and import the project into eclipse

Extract the time, found that the root directory has a debug.keystore file, this file is critical oh.
And then we run a look and you find that sharing is simply not successful, is it a micro-credit reason, of course not.

Third: In the above mentioned project root directory there is a Debug.keystore file, because we compile, signature apk, with the Debug.keystore, each computer is not the same signature file, and micro-letter that App_ ID has signed the file Debug.keystore bound, so why we run directly is not successful.

The solution is to copy the Debug.keystore of the micro-letter to our computer's default Debug.keystore location and overwrite it (recommended for backup).

In the window system, this signature file is in the C:\ user \ Your username \.android directory (note that the Android folder is hidden by default).

Run again and share it successfully.

If it is our application, we will replace the app_id with the app_id that we have applied on the official web site.

In fact, we share information to micro-mail, there is a simpler way, without its SDK API, directly invoke the micro-letter related activity, this is more convenient, such as:

/** * sharing information to friends * * @param file, if the path of the picture is the way, then file = new file (path); 
    * * private void Sharetofriend (file file) {Intent Intent = new Intent (); 
    ComponentName componentname = new ComponentName ("com.tencent.mm", "Com.tencent.mm.ui.tools.ShareImgUI"); 
    Intent.setcomponent (componentname); 
    Intent.setaction (Intent.action_send); 
    Intent.settype ("image/*"); 
    Intent.putextra (Intent.extra_text, "Test micro-letter"); 
    Intent.putextra (Intent.extra_stream, Uri.fromfile (file)); 
StartActivity (Intent); }
/** 
* Share information to the Friends Circle 
* * 
@param file, if the path of the picture, then file = new file (path); 
* * 
private void Sharetotimeline (file file) { 
    Intent Intent = new Intent (); 
    ComponentName componentname = new ComponentName ("com.tencent.mm", "Com.tencent.mm.ui.tools.ShareToTimeLineUI"); 
    Intent.setcomponent (componentname); 
    Intent.setaction (intent.action_send); 
    Intent.putextra (Intent.extra_stream, Uri.fromfile (file));   intent.setaction (Android.content.Intent.ACTION_SEND_MULTIPLE);   arraylist<uri> uris = new arraylist<uri> (); 
for   (int i = 0; i < images.size (); i++) { 
//     Uri data = uri.fromfile (New File (Thumbpaths.get (i))); 
   //     uris.add (data);   } 
//   Intent.putparcelablearraylistextra (Intent.extra_stream, URIs); 
    Intent.settype ("image/*"); 
    StartActivity (intent); 
} 

I hope this article will help you with the Android program.

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.