search
HomeWeChat AppletWeChat DevelopmentDetailed explanation of Android programming method to implement WeChat sharing information

The example of this article tells the story of AndroidProgramming to realize WeChat sharing information The method is shared with everyone for your reference, as follows:

As WeChat becomes more and more popular, more and more applications require the function of sharing to WeChat. Although many platforms have integrated sharing. Functions, such as Umeng. However, I personally feel that Umeng integrates too many things and encapsulates them too much. Many resource files have to be brought in, so it doesn’t feel very good, so I also studied WeChat’s SDK. Share.

First: Download the official sdk demo

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

Second: Unzip and import the project into eclipse

When decompressed, I found a debug.keystore file in the root directory. This file is very The key is.
Then let’s run it and see. You will find that the sharing is not successful at all. Is it because of WeChat? Of course not.

Third: There is one in the root directory of the project mentioned above. debug.keystore file, because when we compile and sign the apk, we use the debug.keystore that comes with us. Each computer has a different signature file, and the WeChat APP_ID has been bound to the signature file debug.keystore , so why is it unsuccessful when we run it directly?

The solution is to copy the debug.keystore of WeChat to the default debug.keystore location of our computer and overwrite it (it is recommended to back it up first).

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 it again and share it. It's successful.

If it's our application, just replace the APP_ID with the APP_ID we applied for on the official website.

In fact, there is a simpler way for us to share information on WeChat. , without using the provided SDK API, it is easier to directly call WeChat related activities, for example:

/** 
* 分享信息到朋友 
* 
* @param file,假如图片的路径为path,那么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, "测试微信"); 
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); 
    startActivity(intent); 
}
/** 
* 分享信息到朋友圈 
* 
* @param file,假如图片的路径为path,那么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 be helpful to everyone in Android programming

.

The above is the detailed content of Detailed explanation of Android programming method to implement WeChat sharing information. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools