package android;

import android.util.Log;
import com.tencent.mm.sdk.modelbase.BaseReq;
import com.tencent.mm.sdk.modelbase.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.jianzhi_inc.dandelion.wechat.WeChat;


public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.e("WXShare", "entry activity oncreate called");
        super.onCreate(savedInstanceState);
        WeChat.api.handleIntent(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        Log.e("WXShare", "entry activity onNewIntent called");
        setIntent(intent);
        WeChat.api.handleIntent(intent, this);
    }

    protected void startMainActivity() {
        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setPackage(getApplicationContext().getPackageName());
        getApplicationContext().startActivity(intent);
    }

    @Override
    public void onReq(BaseReq req) {
        // not implemented
        finish();
    }

    @Override
    public void onResp(BaseResp resp) {
        switch (resp.errCode) {
            case BaseResp.ErrCode.ERR_OK:
                WeChat.currentCallbackContext.success();
                break;
            case BaseResp.ErrCode.ERR_USER_CANCEL:
                WeChat.currentCallbackContext.error(WeChat.ERR_USER_CANCEL);
                break;
            case BaseResp.ErrCode.ERR_AUTH_DENIED:
                WeChat.currentCallbackContext.error(WeChat.ERR_AUTH_DENIED);
                break;
            case BaseResp.ErrCode.ERR_SENT_FAILED:
                WeChat.currentCallbackContext.error(WeChat.ERR_SENT_FAILED);
                break;
            case BaseResp.ErrCode.ERR_UNSUPPORT:
                WeChat.currentCallbackContext.error(WeChat.ERR_UNSUPPORT);
                break;
            case BaseResp.ErrCode.ERR_COMM:
                WeChat.currentCallbackContext.error(WeChat.ERR_COMM);
                break;
            default:
                WeChat.currentCallbackContext.error(WeChat.ERR_UNKNOWN);
                break;
        }
        finish();
    }

}
@@ -567,16 +567,264 @@
 State);%0A
+%0A        if (WeChat.api == null) %7B%0A            Log.e(%22WXShare%22, %22========Wechat.wxAPI is null!!!!%22);%0A            startMainActivity();%0A        %7D else %7B%0A            Log.e(%22WXShare%22, %22========Wechat.wxAPI is not null, start to handleIntent----%22);%0A    
         
@@ -859,32 +859,42 @@
 ntent(), this);%0A
+        %7D%0A
     %7D%0A%0A    @Over
@@ -1056,27 +1056,247 @@
     
-setIntent(intent);%0A
+if (WeChat.api == null) %7B%0A            Log.e(%22WXShare%22, %22========Wechat.wxAPI is null!!!!%22);%0A            startMainActivity();%0A        %7D else %7B%0A            Log.e(%22WXShare%22, %22========Wechat.wxAPI is not null, start to handleIntent----%22);%0A    
     
@@ -1323,22 +1323,27 @@
 eIntent(
-i
+getI
 ntent
+()
 , this);
@@ -1339,24 +1339,34 @@
 t(), this);%0A
+        %7D%0A
     %7D%0A%0A    p

Modify WeiXin Entry Activity