package com.bwei.activity;
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.Toast;
public class Activity2 extends Activity {
private WebView wv;
private ImageView iv_fenxiang;
private String title;
private String url;
private String imageurl;
private ImageView iv_shoucang;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置隐藏标题
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 加载xml文件
setContentView(R.layout.activity_activity2);
// 首先在您的Activity中添加如下成员变量
// 取出数据
Intent in = getIntent();
url = in.getStringExtra("url");
title = in.getStringExtra("title");
//imageurl=in.getStringExtra("imageurl");
wv = (WebView) findViewById(R.id.wv);
iv_fenxiang = (ImageView) findViewById(R.id.a2_fenxiang);
iv_shoucang = (ImageView) findViewById(R.id.a2_shoucang);
// 设置参数
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setDefaultTextEncodingName("utf-8");
wv.loadUrl(url);
// wv.setWebChromeClient(client)
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 根据传入的参数访问
wv.loadUrl(url);
// 表示不用跳转网页就可以访问
return true;
}
});
// 为分享按钮设置监听
iv_fenxiang.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//UMImage image = new UMImage(Activity2.this, imageurl);
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(Activity2.this).setDisplayList( displaylist )
.withText( "新闻" )
.withTitle(title)
.withTargetUrl(url)
//.withMedia( image )
.setListenerList(umShareListener)
.open();
}
UMShareListener umShareListener =new UMShareListener() {
@Override
public void onResult(SHARE_MEDIA platform) {
Toast.makeText(Activity2.this,platform + " 分享成功啦", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(Activity2.this,platform + " 分享失败啦", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(Activity2.this,platform + " 分享取消了", Toast.LENGTH_SHORT).show();
}
};
});
//为收藏按钮设置监听
iv_shoucang.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
}
}
import com.umeng.socialize.ShareAction;
import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.Toast;
public class Activity2 extends Activity {
private WebView wv;
private ImageView iv_fenxiang;
private String title;
private String url;
private String imageurl;
private ImageView iv_shoucang;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置隐藏标题
requestWindowFeature(Window.FEATURE_NO_TITLE);
// 加载xml文件
setContentView(R.layout.activity_activity2);
// 首先在您的Activity中添加如下成员变量
// 取出数据
Intent in = getIntent();
url = in.getStringExtra("url");
title = in.getStringExtra("title");
//imageurl=in.getStringExtra("imageurl");
wv = (WebView) findViewById(R.id.wv);
iv_fenxiang = (ImageView) findViewById(R.id.a2_fenxiang);
iv_shoucang = (ImageView) findViewById(R.id.a2_shoucang);
// 设置参数
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setDefaultTextEncodingName("utf-8");
wv.loadUrl(url);
// wv.setWebChromeClient(client)
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// 根据传入的参数访问
wv.loadUrl(url);
// 表示不用跳转网页就可以访问
return true;
}
});
// 为分享按钮设置监听
iv_fenxiang.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//UMImage image = new UMImage(Activity2.this, imageurl);
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(Activity2.this).setDisplayList( displaylist )
.withText( "新闻" )
.withTitle(title)
.withTargetUrl(url)
//.withMedia( image )
.setListenerList(umShareListener)
.open();
}
UMShareListener umShareListener =new UMShareListener() {
@Override
public void onResult(SHARE_MEDIA platform) {
Toast.makeText(Activity2.this,platform + " 分享成功啦", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(SHARE_MEDIA platform, Throwable t) {
Toast.makeText(Activity2.this,platform + " 分享失败啦", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel(SHARE_MEDIA platform) {
Toast.makeText(Activity2.this,platform + " 分享取消了", Toast.LENGTH_SHORT).show();
}
};
});
//为收藏按钮设置监听
iv_shoucang.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
}
}