SoFunction
Updated on 2025-04-09

Simple implementation of android third-party sharing method

Currently there are two ways to share with third parties:

1. It is necessary to integrate the official SDK package, and after obtaining official authorization, it calls its API to complete sharing on WeChat, Weibo, etc.
Advantages: Seamless integration, multiple functions
Disadvantages: Integrate the official SDK package for development, and require application for official authorization
2. Directly adjust the activities of WeChat, Weibo, etc. to share
Advantages: It is very simple, and does not require SDK and official authorization
Disadvantages: WeChat and Weibo clients need to be installed locally

Here I will introduce the second sharing method, which is applicable in AppTrea and Android version of Baihua Camera.

Typical codes are as follows:

@Override 
public void onClick(View v) 
{ 
String pakName = ""; 
Intent intent = new Intent(Intent.ACTION_SEND); // Start sharing and sending attributes("text/plain"); // Share the type of data sentswitch (()) 
{ 
case 0: 
pakName = ""; //qq spacebreak; 
case 1: 
pakName = ""; //Tencent Weibobreak; 
case 2: 
pakName = ""; //WeChatbreak; 
 
 
default: 
break; 
} 
(pakName); 
(Intent.EXTRA_SUBJECT, "This is the topic of sharing"); // Shared topics(Intent.EXTRA_TEXT, "This is sharing content"); // Shared content((intent, ""));// The title of the target application selection dialog box;} 

It is also very simple to make your activity support this calling method, just add it to the xml

<intent-filter>
    <action android:name="" />
    <category android:name="" />
</intent-filter>

Just do it.

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.