1
This commit is contained in:
@@ -64,8 +64,8 @@ public class MyApplication extends Application{
|
||||
// CrashHandler crashHandler = CrashHandler.getInstance();
|
||||
// crashHandler.init(this);
|
||||
Bugly.init(this,"d45325664f",false);
|
||||
System.setProperty("http.proxyHost", "haotian.hoheng.cn");
|
||||
System.setProperty("http.proxyPort", "8080");
|
||||
// System.setProperty("http.proxyHost", "haotian.hoheng.cn");
|
||||
// System.setProperty("http.proxyPort", "8080");
|
||||
|
||||
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
|
||||
StrictMode.setVmPolicy(builder.build());
|
||||
|
||||
@@ -9,6 +9,11 @@ import android.widget.TextView;
|
||||
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
import com.sl.house_property.R;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
|
||||
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import utils.QRCodeUtil;
|
||||
|
||||
@@ -19,6 +24,29 @@ public class ShareCodeDialog extends CenterPopupView {
|
||||
private ImageView ivCode;
|
||||
private TextView tvShare;
|
||||
private TextView tvCancel;
|
||||
// APP_ID 替换为你的应用从官方网站申请到的合法appID
|
||||
private static final String APP_ID = "wx7e09fff168f6e58d";
|
||||
// IWXAPI 是第三方app和微信通信的openApi接口
|
||||
private IWXAPI api;
|
||||
|
||||
private void regToWx() {
|
||||
// 通过WXAPIFactory工厂,获取IWXAPI的实例
|
||||
api = WXAPIFactory.createWXAPI(getContext(), APP_ID, true);
|
||||
|
||||
// 将应用的appId注册到微信
|
||||
api.registerApp(APP_ID);
|
||||
|
||||
// //建议动态监听微信启动广播进行注册到微信
|
||||
// registerReceiver(new BroadcastReceiver() {
|
||||
// @Override
|
||||
// public void onReceive(Context context, Intent intent) {
|
||||
//
|
||||
// // 将该app注册到微信
|
||||
// api.registerApp(Constants.APP_ID);
|
||||
// }
|
||||
// }, new IntentFilter(ConstantsAPI.ACTION_REFRESH_WXAPP));
|
||||
|
||||
}
|
||||
|
||||
public ShareCodeDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
@@ -43,6 +71,7 @@ public class ShareCodeDialog extends CenterPopupView {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
regToWx();
|
||||
tvShare.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -50,10 +79,29 @@ public class ShareCodeDialog extends CenterPopupView {
|
||||
}
|
||||
});
|
||||
tvPwd.setText("密码:" + pwd);
|
||||
Bitmap qrCodeBitmap = QRCodeUtil.createQRCodeBitmap(code, QRCodeUtil.dip2px(getContext(),220), QRCodeUtil.dip2px(getContext(),220));
|
||||
final Bitmap qrCodeBitmap = QRCodeUtil.createQRCodeBitmap(code, QRCodeUtil.dip2px(getContext(), 220), QRCodeUtil.dip2px(getContext(), 220));
|
||||
ivCode.setImageBitmap(qrCodeBitmap);
|
||||
}
|
||||
findViewById(R.id.tv_share).setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
//初始化 WXImageObject 和 WXMediaMessage 对象
|
||||
WXImageObject imgObj = new WXImageObject(qrCodeBitmap);
|
||||
WXMediaMessage msg = new WXMediaMessage();
|
||||
msg.mediaObject = imgObj;
|
||||
msg.title = "临时门禁";
|
||||
msg.description="临时门禁";
|
||||
//构造一个Req
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.transaction = "img";
|
||||
req.message = msg;
|
||||
req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
// req.userOpenId = getOpenId();
|
||||
//调用api接口,发送数据到微信
|
||||
api.sendReq(req);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void setPwd(String pwd) {
|
||||
|
||||
Reference in New Issue
Block a user