import android.app.Application;
import android.content.Context;
import com.umeng.socialize.PlatformConfig;
/**
* Created by ntop on 15/7/8.
*/
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
}
//各个平台的配置,建议放在全局Application或者程序入口
{
//微信 wx12342956d1cab4f9,a5ae111de7d9ea137e88a5e02c07c94d
PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
//豆瓣RENREN平台目前只能在服务器端配置
//新浪微博
PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad");
//易信
PlatformConfig.setYixin("yxc0614e80c9304c11b0391514d09f13bf");
PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
PlatformConfig.setTwitter("3aIN7fuF685MuZ7jtXkQxalyi", "MK6FEYG63eWcpDFgRYw4w9puJhzDl0tyuqWjZ3M7XJuuG7mMbO");
PlatformConfig.setAlipay("2015111700822536");
PlatformConfig.setLaiwang("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e");
PlatformConfig.setPinterest("1439206");
}
}
package com.example.shard;
import android.app.Activity;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.ShareContent;
import com.umeng.socialize.UMShareAPI;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.editorpage.ShareActivity;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMVideo;
import com.umeng.socialize.media.UMusic;
import com.umeng.socialize.shareboard.SnsPlatform;
import com.umeng.socialize.utils.ShareBoardlistener;
public class MainActivity extends Activity {
private UMImage image;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = new UMImage(this, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
}
public void open(View v) {
// UMImage image = new UMImage(this, "http://www.umeng.com/images/pic/social/integrated_3.png");
UMVideo video = new UMVideo("http://video.sina.com.cn/p/sports/cba/v/2013-10-22/144463050817.html");
new ShareAction(this).setDisplayList(SHARE_MEDIA.SINA,SHARE_MEDIA.QQ/*,SHARE_MEDIA.QZONE,SHARE_MEDIA.WEIXIN,SHARE_MEDIA.WEIXIN_CIRCLE*/)
.withText("来自友盟分享面板")
// .withMedia(image)
.withTargetUrl("http://www.baidu.com")
.setCallback(umShareListener)
.open();
/*
* new ShareAction(this) .setPlatform(SHARE_MEDIA.QQ)
* .setCallback(umShareListener) .withText("Hello 豆瓣") .withMedia(image)
* .share();
*/
}
public void qq (View v){
new ShareAction(this) .setPlatform(SHARE_MEDIA.QQ)
.setCallback(umShareListener) .withText("Hello qq") .withTitle("标题").withTargetUrl("http://www.baidu.com")
.share();
}
private UMShareListener umShareListener = new UMShareListener() {
@Override
public void onResult(SHARE_MEDIA platform) {
Toast.makeText(MainActivity.this, platform + " 分享成功啦",
Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(MainActivity.this, platform + " 分享失败啦",
Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(MainActivity.this, platform + " 分享取消了",
Toast.LENGTH_SHORT).show();
}
};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
}
}
package com.example.shard;
import com.umeng.socialize.media.WBShareCallBackActivity;
/**
* Created by wangfei on 15/12/3.
*/
public class WBShareActivity extends WBShareCallBackActivity{
}