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

adnroid:修复回调的bug

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