@@ -25,7 +25,7 @@ | |||||
<uses-feature android:name="android.hardware.camera.autofocus" /> | <uses-feature android:name="android.hardware.camera.autofocus" /> | ||||
<application | <application | ||||
android:name="io.flutter.app.FlutterApplication" | |||||
android:name="cn.zhios.zhiying_base_widget_example.MyFlutterApplication" | |||||
android:icon="@mipmap/ic_launcher" | android:icon="@mipmap/ic_launcher" | ||||
android:label="@string/app_name" | android:label="@string/app_name" | ||||
android:allowBackup="true" | android:allowBackup="true" | ||||
@@ -10,6 +10,9 @@ import android.view.WindowManager; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import com.example.moblink.MoblinkPlugin; | |||||
import com.mob.moblink.MobLink; | |||||
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -30,6 +33,9 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN | |||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
configureWindowForTransparency(); | configureWindowForTransparency(); | ||||
configureStatusBarForFullscreenFlutterExperience(); | configureStatusBarForFullscreenFlutterExperience(); | ||||
MobLink.setRestoreSceneListener(new MoblinkPlugin.SceneListener()); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -71,25 +77,25 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN | |||||
} | } | ||||
@Override | |||||
public Map getSetting() { | |||||
Map map = new HashMap(); | |||||
map.put("domain", "http://inapi.izhyin.cn"); //"http://120.76.175.204:8989"); | |||||
@Override | |||||
public Map getSetting() { | |||||
Map map = new HashMap(); | |||||
map.put("domain", "http://inapi.izhyin.cn"); //"http://120.76.175.204:8989"); | |||||
// map.put("domain", "http://192.168.0.113:5000"); | // map.put("domain", "http://192.168.0.113:5000"); | ||||
map.put("master_id", "123456"); | |||||
map.put("secret_key", "123456"); | |||||
map.put("master_id", "123456"); | |||||
map.put("secret_key", "123456"); | |||||
// map.put("token", "123465"); | // map.put("token", "123465"); | ||||
return map; | |||||
} | |||||
@Override | |||||
public void invokeMethod(String method, Map<String, Object> params, ZhiyingFlutterCommHandler handler) { | |||||
return; | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
super.onDestroy(); | |||||
ZhiyingFlutterCommNative.getInstance().unregist(); | |||||
} | |||||
return map; | |||||
} | |||||
@Override | |||||
public void invokeMethod(String method, Map<String, Object> params, ZhiyingFlutterCommHandler handler) { | |||||
return; | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
super.onDestroy(); | |||||
ZhiyingFlutterCommNative.getInstance().unregist(); | |||||
} | |||||
} | } |
@@ -0,0 +1,16 @@ | |||||
package cn.zhios.zhiying_base_widget_example; | |||||
import com.example.moblink.MoblinkPlugin; | |||||
import com.mob.moblink.MobLink; | |||||
import io.flutter.app.FlutterApplication; | |||||
public class MyFlutterApplication extends FlutterApplication { | |||||
//防止MobLink在APP杀死进程后无法还原 | |||||
@Override | |||||
public void onCreate() { | |||||
super.onCreate(); | |||||
MobLink.setRestoreSceneListener(new MoblinkPlugin.SceneListener()); | |||||
} | |||||
} |
@@ -65,27 +65,6 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver { | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
// 场景还原,记录邀请码 | |||||
void _restore(MLSDKScene scene) { | |||||
const bool inProduction = const bool.fromEnvironment("dart.vm.product"); | |||||
if (!inProduction) { | |||||
// 非release环境,弹窗测试 | |||||
showAlert('要还原的路径为:' + scene.className + '\n' + scene.params.toString(), | |||||
context); | |||||
} | |||||
Logger.debug('要还原的路径为:' + scene.className); | |||||
try { | |||||
Map<String, dynamic> params = Map<String, dynamic>.from(scene.params); | |||||
if (params.containsKey('tgid')) { | |||||
String tgid = params['tgid'].toString(); | |||||
// 记录邀请码到本地 | |||||
SharedPreferencesUtil.setNetCacheResult(Constants.mobInvitedCode, tgid); | |||||
} | |||||
} catch (e) { | |||||
Logger.debug(e); | |||||
} | |||||
} | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
WidgetsBinding.instance.removeObserver(this); | WidgetsBinding.instance.removeObserver(this); | ||||
@@ -222,16 +201,54 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver { | |||||
IntellectCreate.checkAndCreateFirst(context); | IntellectCreate.checkAndCreateFirst(context); | ||||
} | } | ||||
// 场景还原,记录邀请码 | |||||
void _restore(MLSDKScene scene) { | |||||
// const bool inProduction = const bool.fromEnvironment("dart.vm.product"); | |||||
bool inProduction = false; | |||||
if (!inProduction) { | |||||
// 非release环境,弹窗测试 | |||||
showAlert('要还原的路径为:' + scene.className + '\n' + scene.params.toString(), | |||||
context); | |||||
} | |||||
Logger.debug('要还原的路径为:' + scene.className); | |||||
try { | |||||
Map<String, dynamic> params = Map<String, dynamic>.from(scene.params); | |||||
if (params.containsKey('tgid')) { | |||||
String tgid = params['tgid'].toString(); | |||||
// 记录邀请码到本地 | |||||
SharedPreferencesUtil.setNetCacheResult(Constants.mobInvitedCode, tgid); | |||||
} | |||||
} catch (e) { | |||||
Logger.error(e); | |||||
} | |||||
} | |||||
//app存在后台时候的还原 | //app存在后台时候的还原 | ||||
void _onEvent(Object event) { | void _onEvent(Object event) { | ||||
Logger.debug('返回的内容: $event'); | Logger.debug('返回的内容: $event'); | ||||
if (null != event) { | |||||
showAlert('要还原的路径为[活着]:$event', context); | |||||
try { | |||||
if (null != event) { | |||||
Map<String, dynamic> params = Map<String, dynamic>.from(event); | |||||
// const bool inProduction = const bool.fromEnvironment("dart.vm.product"); | |||||
bool inProduction = false; | |||||
if (!inProduction) { | |||||
// 非release环境,弹窗测试 | |||||
showAlert('要还原的路径为[活着]:$event', context); | |||||
} | |||||
if (params['params'].containsKey('tgid')) { | |||||
String tgid = params['params']['tgid'].toString(); | |||||
// 记录邀请码到本地 | |||||
SharedPreferencesUtil.setNetCacheResult( | |||||
Constants.mobInvitedCode, tgid); | |||||
} | |||||
} | |||||
} catch (e) { | |||||
Logger.error(e); | |||||
} | } | ||||
} | } | ||||
void _onError(Object error) { | void _onError(Object error) { | ||||
Logger.debug('返回的错误'); | |||||
Logger.error('返回的错误: $error'); | |||||
} | } | ||||
void showAlert(String text, BuildContext context) { | void showAlert(String text, BuildContext context) { | ||||