First, get appid and help documentation
In front of me, I introduced the article on Android sharing " Android implementation sharing and considerations" to see the article about QQ sharing.
See Novice boot and access instructions: http://wiki.open.qq.com/wiki/mobile app Access Wiki index
Share related documentation Description: Http://wiki.open.qq.com/index.php?title=Android_API Call description &=45038#1.13_. e5.88.86.e4.ba.ab.e6.b6.88.e6.81.af.e5.88.b0qq.ef.bc.88.e6.97.a0.e9.9c.80qq.e7.99.bb.e5.bd.95.ef.bc.89
Second, the implementation of the code (reprint please indicate source: Http://blog.csdn.net/dawanganban)
public class Qqsharemanager {/** * link */public static final int qq_share_way_webpage = 3;/** * QQ */public static final in t qq_share_type_talk = 1; /** * QQ space */public static final int qq_share_type_zone = 2;/** * Share success */public static final int callback_code_success = 0 ;/** * Cancel share */public static final int callback_code_cancel = 1;/** * Deny access */public static final int callback_code_deny = 2 ;/** * Unknown */public static final int callback_code_unknown = 3;private static String appid;private Tencent Mtencent;private Qqshare qqshare;private qzoneshare qzoneshare;private qqshareresponse qqshareresponse;public void RegistShare (Context Context) {//Initialize data if (appId = = null) {AppId = Qqshareutil.getqqappid (context);} Initialize the share code if (appId! = null && (Qqshare = = NULL | | qzoneshare = = NULL)) {mtencent = Tencent.createinstance (AppId, con text); qqshare = new Qqshare (context, Mtencent.getqqtoken ()); qzoneshare = new Qzoneshare (context, Mtencent.getqqtoken () );}} /** * Share QQ and space * @param sharecontent share content * @parAm Sharetype Select type (QQ, space) */public void sharebyqq (activity activity, sharecontent sharecontent, int sharetype) {SHAREWEBPA GE (activity, sharetype, sharecontent);} private void sharewebpage (activity activity, int sharetype, sharecontent sharecontent) {Bundle params = new bundle (); if (sh Aretype = = Qq_share_type_zone) {Sharewebpageqzone (activity, sharecontent, params);} ELSE{SHAREWEBPAGEQQ (activity, sharecontent, params);}} private void sharewebpageqq (activity activity, sharecontent sharecontent, Bundle params) {params.putstring ( Qqshare.share_to_qq_title, Sharecontent.gettitle ());p arams.putstring (Qqshare.share_to_qq_summary, Sharecontent.getcontent ());p arams.putint (Qqshare.share_to_qq_key_type,qqshare.share_to_qq_type_default); Params.putstring (Qqshare.share_to_qq_target_url, Sharecontent.geturl ());p arams.putstring (QQShare.SHARE_TO_QQ_ Image_url, Sharecontent.getpicurl ());d osharetoqq (activity, params, iuilistener);} private void Sharewebpageqzone (activity activity, sharecontent sharecontent, Bundleparams) {params.putstring (Qzoneshare.share_to_qq_title, Sharecontent.gettitle ());p arams.putstring ( Qzoneshare.share_to_qq_summary, Sharecontent.getcontent ());p Arams.putint (Qzoneshare.share_to_qzone_key_type, Qzoneshare.share_to_qzone_type_image_text);p arams.putstring (Qzoneshare.share_to_qq_target_url, Sharecontent.geturl ()); arraylist<string> imageurls = new arraylist<string> (); Imageurls.add (Sharecontent.getpicurl ()); Params.putstringarraylist (Qzoneshare.share_to_qq_image_url, Imageurls);//params.putstring (QzoneShare.SHARE_TO_ Qq_image_url, Sharecontent.getpicurl ());d osharetoqzone (activity, params, iuilistener);} private void Dosharetoqq (final activity activity, final Bundle params, final Iuilistener iuilistener) {new Thread (new Runn Able () {@Overridepublic void run () {if (qqshare! = null) {QQSHARE.SHARETOQQ (activity, params, iuilistener);}}). Start ();} private void Dosharetoqzone (final activity activity, final Bundle params, final Iuilistener iuilistener) {new Thread (new R Unnable () {@Overridepublic void Run () {if (qzoneshare! = null) {Qzoneshare.sharetoqzone (activity, params, iuilistener);}}). Start ();} Private final Iuilistener Iuilistener = new Iuilistener () {@Overridepublic void OnCancel () {Sendrespcode (Callback_code_ CANCEL);} @Overridepublic void OnComplete (Object response) {Sendrespcode (callback_code_success);} @Overridepublic void OnError (Uierror e) {sendrespcode (callback_code_deny);} private void Sendrespcode (int code) {if (qqshareresponse! = null) {Qqshareresponse.respcode (code);}}; public interface qqshareresponse{/** * Share results * @param code result code */public void Respcode (int code);} /** * Registration Result feedback * @param qqshareresponse */public void Setonqqshareresponse (Qqshareresponse qqshareresponse) { This.qqshareresponse = Qqshareresponse;} /** * Welcome attention-Sunshine Cockroach-http://blog.csdn.net/dawanganban * @author Lixiaoqiang * */private abstract class sharecontent{protected abstract int Getshareway ();p rotected abstract String getcontent ();p rotected abstract String getTitle ();p rotected Abstract STRing GetURL ();p rotected abstract String getpicurl ();} /** * Set the content of the share link * @author Administrator * */public class Sharecontentwebpage extends Sharecontent{private String title;pri Vate string Content;private string Url;private string Picurl;public sharecontentwebpage (string title, string content, Str ing URL, String picurl) {this.title = Title;this.content = Content;this.url = Url;this.picurl = Picurl;} @Overrideprotected String getcontent () {return content;} @Overrideprotected String GetTitle () {return title;} @Overrideprotected String GetURL () {return URL;} @Overrideprotected int Getshareway () {return qq_share_way_webpage;} @Overrideprotected String Getpicurl () {return picurl;}}}
The above realizes the text sharing, the picture sharing and the link sharing interface, hoped to be helpful to the friend who is learning Android and needs.
Another part of the details of the problem and share almost the same, you can refer to " Android implementation sharing and considerations"
Android to realize QQ sharing and matters needing attention