提交 b01fe9be authored 作者: JarvanMo's avatar JarvanMo

adnroid:修复回调的bug

上级 52890bd3
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jarvan.fluwx">
<application>
<activity
android:name=".wxapi.FluwxWXEntryActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:screenOrientation="sensorPortrait"
android:theme="@style/DisablePreviewTheme" />
</application>
</application>
</manifest>
package com.jarvan.fluwx.handler
import com.jarvan.fluwx.constant.WechatPluginKeys
import com.tencent.mm.opensdk.modelmsg.SendAuth
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
......@@ -16,6 +16,7 @@ internal object FluwxAuthHandler {
req.openId = call.argument("openId")
}
result.success(WXAPiHandler.wxApi?.sendReq(req))
}
......
package com.jarvan.fluwx.handler
import android.util.Log
import com.jarvan.fluwx.constant.WeChatPluginMethods
import com.jarvan.fluwx.constant.WechatPluginKeys
import com.tencent.mm.opensdk.modelbase.BaseResp
......@@ -77,6 +78,7 @@ object FluwxResponseHandler {
type to response.type,
WechatPluginKeys.TRANSACTION to response.transaction
)
channel?.invokeMethod("onAuthResponse", result)
}
......
......@@ -3,6 +3,7 @@ package com.jarvan.fluwx.wxapi
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Log
import com.jarvan.fluwx.handler.FluwxResponseHandler
import com.jarvan.fluwx.handler.WXAPiHandler
import com.tencent.mm.opensdk.modelbase.BaseReq
......@@ -38,7 +39,9 @@ open class FluwxWXEntryActivity:Activity(), IWXAPIEventHandler {
// 第三方应用发送到微信的请求处理后的响应结果,会回调到该方法
override fun onResp(resp: BaseResp) {
FluwxResponseHandler.handleResponse(resp)
finish()
}
......
......@@ -35,7 +35,18 @@
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".wxapi.WXEntryActivity" />
<activity android:name=".wxapi.WXPayEntryActivity" />
<activity
android:name="net.sourceforge.simcpux.wxapi.WXEntryActivity"
android:theme="@style/DisablePreviewTheme"
android:exported="true"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="sdksample"/>
</intent-filter>
</activity>
<activity android:name="net.sourceforge.simcpux.wxapi.WXPayEntryActivity" />
</application>
</manifest>
package com.jarvan.fluwxexample
import android.os.Bundle
import net.sourceforge.simcpux.wxapi.WXEntryActivity
import net.sourceforge.simcpux.wxapi.WXPayEntryActivity
import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant
......
package com.jarvan.fluwxexample.wxapi;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
public class WXEntryActivity extends Activity implements IWXAPIEventHandler{
private static final int TIMELINE_SUPPORTED_VERSION = 0x21020001;
private Button gotoBtn, regBtn, launchBtn, checkBtn, scanBtn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
@Override
public void onReq(BaseReq req) {
}
@Override
public void onResp(BaseResp resp) {
}
}
\ No newline at end of file
package com.jarvan.fluwxexample.wxapi;
import android.app.Activity;
import com.jarvan.fluwx.handler.FluwxResponseHandler;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
@Override
public void onReq(BaseReq baseReq) {
}
@Override
public void onResp(BaseResp baseResp) {
FluwxResponseHandler.INSTANCE.handleResponse(baseResp);
}
}
package net.sourceforge.simcpux.wxapi;
import com.jarvan.fluwx.wxapi.FluwxWXEntryActivity;
public class WXEntryActivity extends FluwxWXEntryActivity{
}
\ No newline at end of file
package net.sourceforge.simcpux.wxapi;
import com.jarvan.fluwx.wxapi.FluwxWXEntryActivity;
public class WXPayEntryActivity extends FluwxWXEntryActivity {
}
......@@ -14,6 +14,7 @@ class _ShareTextPageState extends State<ShareTextPage> {
void initState() {
super.initState();
fluwx = new Fluwx();
}
@override
Widget build(BuildContext context) {
......@@ -84,6 +85,8 @@ class _ShareTextPageState extends State<ShareTextPage> {
transaction: "text${DateTime.now().millisecondsSinceEpoch}",
scene: scene
));
// fluwx.sendAuth(WeChatSendAuthModel(scope: "snsapi_userinfo",state: "wechat_sdk_demo_test"));
}
void handleRadioValueChanged(WeChatScene scene){
......
......@@ -38,9 +38,13 @@ class Fluwx {
// static Future unregisterApp(RegisterModel model) async {
// return await _channel.invokeMethod("unregisterApp", model.toMap());
// }
Fluwx(){
_channel.setMethodCallHandler(_handler);
}
void listen() {
_channel.setMethodCallHandler(_handler);
}
void disposeAll() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论