如何實(shí)現(xiàn)友盟第三方登錄與分享

//友盟配置


package="com.example.tadaynews"

android:versionCode="1"

android:versionName="1.0" >

android:minSdkVersion="14"

android:targetSdkVersion="14" />




android:name="com.example.utils.App"

android:icon="@drawable/icon"

android:allowBackup="true"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

android:name="com.example.view.WelcomeActivity"

android:label="@string/app_name" >


android:name="com.example.tadaynews.MainActivity"

android:label="@string/app_name" >


android:name="com.example.login.MoreLoginActivity"

android:label="@string/app_name" >


android:name="com.example.login.LoginActivity"

android:label="@string/app_name" >


android:name="com.example.login.RegisterActivity"

android:label="@string/app_name" >


android:name="com.example.login.RegisterInfo"

android:label="@string/app_name" >


android:name="com.example.view.Left_MenuSetActivity"

android:label="@string/app_name" >


android:name="com.example.login.FindPasswordActivity"

android:label="@string/app_name" >

android:name="com.example.fragment.FragInfoActivity"

android:label="@string/app_name" >

android:name="com.example.view.DownLoadActivity"

android:label="@string/app_name" >


android:name="com.example.tadaynews.SearchActvity"

android:label="@string/app_name" >

android:name="com.example.tadaynews.SourchInfoActivity"

android:label="@string/app_name" >


android:name="com.umeng.socialize.editorpage.ShareActivity"

android:excludeFromRecents="true"

android:theme="@style/Theme.UMDefault" />


android:name="com.umeng.soexample.wxapi.WXEntryActivity"

android:configChanges="keyboardHidden|orientation|screenSize"

android:exported="true"

android:screenOrientation="portrait"

android:theme="@android:style/Theme.Translucent.NoTitleBar" />


android:name=".WBShareActivity"

android:configChanges="keyboardHidden|orientation"

android:screenOrientation="portrait" >

android:name="com.sina.weibo.sdk.component.WeiboSdkBrowser"

android:configChanges="keyboardHidden|orientation"

android:exported="false"

android:windowSoftInputMode="adjustResize" >

android:name="com.sina.weibo.sdk.net.DownloadService"

android:exported="false" >


android:name="com.tencent.tauth.AuthActivity"

android:launchMode="singleTask"

android:noHistory="true" >

android:name="com.tencent.connect.common.AssistActivity"

android:screenOrientation="portrait"

android:theme="@android:style/Theme.Translucent.NoTitleBar" />


android:name="com.example.umeng.WXEntryActivity"

android:configChanges="keyboardHidden|orientation|screenSize"

android:exported="true"

android:screenOrientation="portrait"

android:theme="@android:style/Theme.Translucent.NoTitleBar" />

android:name="UMENG_APPKEY"

android:value="56e7626ee0f55a8a3f0017c9" >


android:name="com.baidu.android.pushservice.PushKeepAlive"

android:theme="@android:style/Theme.Translucent.NoTitleBar"/>



android:process=":bdservice_v1" >



android:process=":bdservice_v1" >

android:process=":bdservice_v1" >


android:exported="true" />






//友盟第三方登錄

package com.example.utils;

import java.util.Map;

import com.umeng.socialize.UMAuthListener;

import com.umeng.socialize.UMShareAPI;

import com.umeng.socialize.bean.SHARE_MEDIA;

import android.app.Activity;

import android.content.Context;

import android.widget.Toast;

/**

* 工具類(lèi)

* 定有友盟,,,第三方登錄 類(lèi),實(shí)現(xiàn)整個(gè)項(xiàng)目的第三方登錄

* @author 淺議愛(ài)

*

*/

public class UmengUtils {

public static void uMengLogin(final Context context,SHARE_MEDIA share){

UMShareAPI mUMAPI = UMShareAPI.get(context);

UMAuthListener uMengShare = new UMAuthListener() {

@Override

// 鎴愬姛

public void onComplete(SHARE_MEDIA platform, int action,

Map data) {

Toast.makeText(context.getApplicationContext(), "Authorize succeed",

Toast.LENGTH_SHORT).show();

}

@Override

// 澶辮觸

public void onError(SHARE_MEDIA platform, int action, Throwable t) {

Toast.makeText(context.getApplicationContext(), "Authorize fail",

Toast.LENGTH_SHORT).show();

}

@Override

// 鍙栨秷

public void onCancel(SHARE_MEDIA platform, int action) {

Toast.makeText(context.getApplicationContext(), "Authorize cancel",

Toast.LENGTH_SHORT).show();

}

};

mUMAPI.doOauthVerify((Activity) context, share, uMengShare);

}

}

//工具類(lèi)

/**

*

*/

package com.example.utils;

import com.umeng.socialize.PlatformConfig;

import android.app.Application;

/**

* @author WJL

*

*/

public class App extends Application {

@Override

public void onCreate() {

// TODO Auto-generated method stub

super.onCreate();

// 寰俊 appid appsecret

PlatformConfig.setWeixin("wx967daebe835fbeac",

"5bb696d9ccd75a38c8a0bfe0675559b3");

// 鏂版氮寰崥 appkey appsecret

PlatformConfig.setSinaWeibo("3921700954",

"04b48b094faeb16683c32669824ebdad");

// QQ鍜孮zone appid appkey

PlatformConfig.setQQZone("1105181363",

" ?nOSNQJcIQSRw3a03");

}

}

//友盟分享

package com.example.fragment;

import java.util.List;

import com.example.bean.ObjectData;

import com.example.tadaynews.R;

import com.umeng.socialize.Config;

import com.umeng.socialize.PlatformConfig;

import com.umeng.socialize.ShareAction;

import com.umeng.socialize.UMShareListener;

import com.umeng.socialize.bean.SHARE_MEDIA;

import com.umeng.socialize.shareboard.SnsPlatform;

import com.umeng.socialize.utils.ShareBoardlistener;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.webkit.WebView;

import android.widget.ImageView;

/**

*

* 該頁(yè)面,顯示詳情頁(yè)面,點(diǎn)擊分享按鈕,進(jìn)行分享

* @author 淺議愛(ài)

*

*/

public class FragInfoActivity extends Activity {

private UMShareListener umShareListener;

private ShareBoardlistener shareBoardlistener;

private WebView mWebView;

private ImageView shareImageView;//分享按鈕

private List list_data;

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.frag_info);

PlatformConfig.setQQZone("100424468",

"c7394704798a158208a74ab60104f0ba");

PlatformConfig.setWeixin("wx967daebe835fbeac",

"5bb696d9ccd75a38c8a0bfe0675559b3");

// 微信 appid appsecret

PlatformConfig.setSinaWeibo("3921700954",

"04b48b094faeb16683c32669824ebdad");

// 新浪微博 appkey appsecret

PlatformConfig.setQQZone("100424468",

"c7394704798a158208a74ab60104f0ba");

// QQ和Qzone appid appkey

PlatformConfig.setAlipay("2015111700822536");

// 支付寶 appid

PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");

// 易信 appkey

PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi",

"MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");

// Twitter appid appkey

PlatformConfig.setPinterest("1439206");

// Pinterest appid

PlatformConfig.setLaiwang("laiwangd497e70d4",

"d497e70d4c3e4efeab1381476bac4c5e");

share();

mWebView=(WebView) findViewById(R.id.mywebview);

shareImageView=(ImageView) findViewById(R.id.share_image);

Intent it=getIntent();

String url=(String) it.getSerializableExtra("web_url");

list_data=(List) it.getSerializableExtra("data");

mWebView.loadUrl(url);

//設(shè)置監(jiān)聽(tīng),點(diǎn)擊,進(jìn)行分享,分享數(shù)據(jù)

shareImageView.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

Config.OpenEditor = false;

final SHARE_MEDIA[] displaylist = new SHARE_MEDIA[] {

SHARE_MEDIA.WEIXIN, SHARE_MEDIA.WEIXIN_CIRCLE,

SHARE_MEDIA.SINA, SHARE_MEDIA.QQ, SHARE_MEDIA.QZONE,

SHARE_MEDIA.DOUBAN };

new ShareAction(FragInfoActivity.this).setDisplayList(displaylist)

.setShareboardclickCallback(shareBoardlistener).open();

}

});

}

/**

*

* 分享調(diào)用的方法

*/

private void share() {

// TODO Auto-generated method stub

umShareListener=new UMShareListener() {

//分享成功

@Override

public void onResult(SHARE_MEDIA arg0) {

// TODO Auto-generated method stub

}

//分享失敗

@Override

public void onError(SHARE_MEDIA arg0, Throwable arg1) {

// TODO Auto-generated method stub

}

//取消分享

@Override

public void onCancel(SHARE_MEDIA arg0) {

// TODO Auto-generated method stub

}

};

//shareBoardlistener=new ShareBoardlistener() {

////選擇要分享的數(shù)據(jù)

//@Override

//public void onclick(SnsPlatform arg0, SHARE_MEDIA arg1) {

//// TODO Auto-generated method stub

//if (arg1 == null) {

//if (arg0.mKeyword.equals("11")) {

//}

//} else {

//// 設(shè)置分享的內(nèi)容

//new ShareAction(FragInfoActivity.this)

//.setPlatform(arg1)

//.setCallback(umShareListener)

//.withText(list_data.getContent())

//.withTitle(list_data.getTitle())

//.withTargetUrl(list_data.getDisplay_url())

//.setListenerList(umShareListener).share();

//}

//}

//};

}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 轉(zhuǎn)自:http://www.itdecent.cn/p/d455025d5882 產(chǎn)品概述 Android U-s...
    enchanted1107閱讀 1,198評(píng)論 0 1
  • afinalAfinal是一個(gè)android的ioc,orm框架 https://github.com/yangf...
    passiontim閱讀 15,873評(píng)論 2 45
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,034評(píng)論 25 709
  • 和曉霜,明明 組建好 Hodor 隊(duì),給自己準(zhǔn)備了雞血視頻如下: 1.當(dāng)幸福來(lái)敲門(mén) 2.肖申克的救贖 3.阿甘正傳...
    Chew_Lin閱讀 279評(píng)論 0 1
  • 你和豆豆相互打了對(duì)方,誰(shuí)都不愿意理會(huì)對(duì)方。我是這樣做的,讓你們稍微轉(zhuǎn)移注意力,說(shuō),你的嘴巴怎么變成這樣了,一...
    豆蔻媽閱讀 185評(píng)論 0 0

友情鏈接更多精彩內(nèi)容