安卓接入微信登录,onCreate不会执行
澳门赌场开户
澳门赌场开户
当前位置 : 澳门赌场开户 > 网上赌博新址

安卓接入微信登录,onCreate不会执行

代码都贴出来

WXEntryActivity.java

package com.vivigames.scmj.wxapi;

import org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;

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.SendAuth;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.vivigames.scmj.Constants;
import com.vivigames.scmj.WXAPI;
import com.tencent.mm.sdk.openapi.WXTextObject;

public class WXEntryActivity extends Activity implements IWXAPIEventHandler {

    private IWXAPI _api;

    @Override
    public void onCreateBundle savedInstanceState {
        super.onCreatesavedInstanceState;
        //setContentViewR.layout.plugin_entry;
        Log.d"WXEntryActivity", "onCreate";
        _api = WXAPIFactory.createWXAPIthis, Constants.APP_ID, false;
        //_api.registerAppConstants.APP_ID;
        _api.handleIntentgetIntent, this;
    }

    @Override
    protected void onNewIntentIntent intent {
        super.onNewIntentintent;

        setIntentintent;
        _api.handleIntentintent, this;
    }

    @Override
    public void onReqBaseReq req {
        /*
        switch req.getType {
        case ConstantsAPI.COMMAND_GETMESSAGE_FROM_WX:
            //goToGetMsg;
            break;
        case ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX:
            //goToShowMsgShowMessageFromWX.Req req;
            break;
        default:
            break;
        }
        */
        this.finish;
    }

    @Override
    public void onRespBaseResp resp {
        int result = 0;
        switch resp.errCode {
            case BaseResp.ErrCode.ERR_OK:
                if WXAPI.isLogin {
                    SendAuth.Resp authResp = SendAuth.Resp resp;
                    if authResp != null && authResp.token != null {
                        Cocos2dxJavascriptJavaBridge.evalString"cc.vv.anysdkMgr.onLoginResp" + authResp.token + "";
                    }
                }
                break;
            case BaseResp.ErrCode.ERR_USER_CANCEL:
                result = 2;//R.string.errcode_cancel;
                break;
            case BaseResp.ErrCode.ERR_AUTH_DENIED:
                result = 3;//R.string.errcode_deny;
                break;
            default:
                result = 4;//R.string.errcode_unknown;
                break;
        }
        this.finish;

        //Toast.makeTextthis, result, Toast.LENGTH_LONG.show;
    }
}

WXAPI.java

package com.vivigames.scmj;

import android.app.Activity;
import android.content.Context;

import com.tencent.mm.sdk.openapi.IWXAPI;
import com.tencent.mm.sdk.openapi.SendAuth;
import com.tencent.mm.sdk.openapi.SendMessageToWX;
import com.tencent.mm.sdk.openapi.WXAPIFactory;
import com.tencent.mm.sdk.openapi.WXMediaMessage;
import com.tencent.mm.sdk.openapi.WXWebpageObject;


public class WXAPI {
    public static IWXAPI api;
    public static Activity instance;
    public static boolean isLogin = false;
    public static void InitActivity context{
        WXAPI.instance = context;
        api = WXAPIFactory.createWXAPIcontext, Constants.APP_ID, true;
        api.registerAppConstants.APP_ID;
    }
    
    private static String buildTransactionfinal String type {
        return type == null ? String.valueOfSystem.currentTimeMillis : type + System.currentTimeMillis;
    }
    
    public static void Login{
        isLogin = true;
        final SendAuth.Req req = new SendAuth.Req;
        req.scope = "snsapi_userinfo";
        req.state = "carjob_wx_login";
        api.sendReqreq;
        //instance.finish;
    }
    
    public static void ShareString url,String title,String desc{
        try{
            isLogin = false;
            WXWebpageObject webpage = new WXWebpageObject;
            webpage.webpageUrl = url;
            WXMediaMessage msg = new WXMediaMessagewebpage;
            msg.title = title;
            msg.description = desc;
            //msg.thumbData = Util.bmpToByteArraythumbBmp, true;
            
            SendMessageToWX.Req req = new SendMessageToWX.Req;
            req.transaction = buildTransaction"webpage";
            req.message = msg;
            req.scene = /*isTimelineCb.isChecked ? SendMessageToWX.Req.WXSceneTimeline : */SendMessageToWX.Req.WXSceneSession;
            api.sendReqreq;
            //instance.finish;
        }
        catchException e{
            e.printStackTrace;
        }
    }
}

AndroidMainfest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.vivigames.scmj"
    android:installLocation="auto">

    <uses-feature android:glEsVersion="0x00020000" />
    
    <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@mipmap/ic_launcher">
        
        <!-- Tell Cocos2dxActivity the name of our .so -->
        <meta-data android:name="android.app.lib_name"
                   android:value="cocos2djs" />
        
        <activity
            android:name="org.cocos2dx.javascript.AppActivity"
            android:screenOrientation="sensorLandscape"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".wxapi.WXEntryActivity"
            android:label="@string/app_name"
            android:exported="true"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>  
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>  
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>  
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>  
    
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.RESTART_PACKAGES" />
    <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
</manifest>

点击按钮能够调用到Login方法,可是初始化的时候没有调用onCreate方法,新手一枚,求指教

我把AndroidMainfest下的name为org.cocos2dx.javascript.AppActivity

<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

注销掉,WXEntryActivity下的onCreate方法才会被调用
可是还是不知道怎么解决

栏目列表

广告位

澳门赌场开户