萝莉来了 v1.2.1版本的 MD5 值为:6055c21e001561c5b114d0da5b392fcb
以下内容为反编译后的 WXEntryActivity.java 源代码,内容仅作参考
package com.gamegoo.loligo.wxapi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.gamegoo.loligo.util.Tutil;
import com.gamegoo.loligo.vampire;
import com.tencent.mm.sdk.openapi.BaseReq;
import com.tencent.mm.sdk.openapi.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.tencent.mm.sdk.openapi.WXImageObject;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXTextObject;
import com.tencent.mm.sdk.platformtools.Util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
private static final int THUMB_SIZE = 150;
public static final int TIMELINE_SUPPORTED_VERSION = 553779201;
public static final String kAppID = "wx64887a68eb6a9513";
public static final String kAppKey = "d5794271016b251b71f137100a80ace6";
public static final String kDefaultShareImage = "screenshot.png";
public static final String kPKSuccessTxt = "哈哈,我在萝莉来了排行榜里超过你啦!";
public static final String kShareDesc = "快来一起玩吧";
private static final String kShareSuccessText = "分享成功";
public static final String kShareText = "爱速度,爱激情,爱萝莉,爱冲击,不喜欢停止战斗,只爱勇往直前,我玩的是萝莉来了. 下载: http://llll.punchbox.org";
private LinearLayout mLinearLayout = null;
public static IWXAPI api = null;
private static WXEntryActivity s_instance = null;
public static native void getAndroidDeviceUID(String str);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
s_instance = this;
api = WXAPIFactory.createWXAPI(this, kAppID, true);
api.handleIntent(getIntent(), this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
api.handleIntent(intent, this);
System.out.println("weixin: onNewIntent");
}
void drawImage(String file) {
this.mLinearLayout = new LinearLayout(this);
ImageView i = new ImageView(this);
try {
FileInputStream fis = new FileInputStream(new File(file));
i.setImageBitmap(BitmapFactory.decodeStream(fis));
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
i.setAdjustViewBounds(true);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(i.getWidth(), i.getHeight());
layoutParams.gravity = 17;
i.setLayoutParams(layoutParams);
this.mLinearLayout.addView(i);
setContentView(this.mLinearLayout);
} catch (FileNotFoundException e2) {
e2.printStackTrace();
}
}
public static void shareText() {
vampire.I();
if (!vampire.api.isWXAppInstalled()) {
vampire.I();
vampire.showStringDialog("请安装微信客户端");
return;
}
System.out.println("weixin: Share to weixin");
WXTextObject textObj = new WXTextObject();
textObj.text = kShareText;
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
msg.description = kShareDesc;
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = String.valueOf(System.currentTimeMillis());
req.message = msg;
vampire.I();
if (vampire.api.getWXAppSupportAPI() >= 553779201) {
req.scene = 1;
}
vampire.I();
boolean ok = vampire.api.sendReq(req);
System.out.println("weixin: sendReq " + (ok ? "ok" : "fail"));
}
public static void shareImage() {
vampire.I();
if (!vampire.api.isWXAppInstalled()) {
vampire.I();
vampire.showStringDialog("请安装微信客户端");
return;
}
System.out.println("weixin: Share to weixin");
String file = Tutil.getWriteablePath(vampire.I()) + kDefaultShareImage;
Bitmap bmp = null;
try {
FileInputStream fis = new FileInputStream(new File(file));
bmp = BitmapFactory.decodeStream(fis);
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
if (bmp != null) {
WXImageObject imgObj = new WXImageObject(bmp);
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = imgObj;
Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp, THUMB_SIZE, THUMB_SIZE, true);
bmp.recycle();
msg.thumbData = Util.bmpToByteArray(thumbBmp, true);
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = buildTransaction("img");
req.message = msg;
vampire.I();
if (vampire.api.getWXAppSupportAPI() >= 553779201) {
req.scene = 1;
} else {
req.scene = 0;
}
vampire.I();
boolean ok = vampire.api.sendReq(req);
System.out.println("weixin: sendReq img " + (ok ? "ok" : "fail"));
}
}
public static void pushTextToWx(String txt) {
vampire.I();
if (!vampire.api.isWXAppInstalled()) {
vampire.I();
vampire.showStringDialog("请安装微信客户端");
return;
}
System.out.println("weixin: pushTextToWx Share to weixin");
WXTextObject textObj = new WXTextObject();
textObj.text = kShareText;
WXMediaMessage msg = new WXMediaMessage();
msg.mediaObject = textObj;
msg.description = kShareDesc;
SendMessageToWX.Req req = new SendMessageToWX.Req();
req.transaction = String.valueOf(System.currentTimeMillis());
req.message = msg;
req.scene = 0;
vampire.I();
boolean ok = vampire.api.sendReq(req);
System.out.println("weixin: pushTextToWx sendReq " + (ok ? "ok" : "fail"));
}
private static String buildTransaction(String type) {
return type == null ? String.valueOf(System.currentTimeMillis()) : type + System.currentTimeMillis();
}
@Override
public void onReq(BaseReq req) {
switch (req.getType()) {
case 3:
System.out.println("weixin: onReq ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX");
return;
case 4:
System.out.println("weixin: onReq ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX");
return;
default:
System.out.println("weixin: onReq " + req.getType());
return;
}
}
@Override
public void onResp(BaseResp resp) {
switch (resp.errCode) {
case BaseResp.ErrCode.ERR_AUTH_DENIED:
System.out.println("weixin: share to weixin denied");
break;
case -2:
System.out.println("weixin: share to weixin cancel");
break;
case 0:
System.out.println("weixin: share to weixin ok");
vampire.I();
vampire.showStringDialog(kShareSuccessText);
vampire.I();
vampire.sendEventFromJavaToCpp(vampire.s_jc_share_wx_success, null, null);
break;
}
finish();
}
}