|
@@ -1,8 +1,36 @@
|
|
|
+import 'dart:io';
|
|
|
+import 'package:device_apps/device_apps.dart' as app;
|
|
|
import 'package:android_intent/android_intent.dart';
|
|
|
import 'package:android_intent/flag.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:sport/utils/toast.dart';
|
|
|
import 'package:sport/widgets/button_primary.dart';
|
|
|
|
|
|
+
|
|
|
+Future startRun(BuildContext context) async {
|
|
|
+ var package = "com.ouj.hiyd";
|
|
|
+ var componentName = "com.ouj.hiyd.SplashActivity_";
|
|
|
+
|
|
|
+ if (Platform.isAndroid) {
|
|
|
+ var sport = await app.DeviceApps.getApp(package);
|
|
|
+ if(sport == null) {
|
|
|
+ ToastUtil.show("你还没安装 Hi运动 app");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ AndroidIntent intent = AndroidIntent(
|
|
|
+ action: "android.intent.action.MAIN",
|
|
|
+ package: package,
|
|
|
+ componentName: componentName,
|
|
|
+ flags: [
|
|
|
+ Flag.FLAG_ACTIVITY_NEW_TASK
|
|
|
+ ],
|
|
|
+ arguments: {
|
|
|
+
|
|
|
+ });
|
|
|
+ intent.launch();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
class GameRun extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
@@ -42,18 +70,7 @@ class GameRun extends StatelessWidget {
|
|
|
height: 35,
|
|
|
content: "开始跑步",
|
|
|
callback: () {
|
|
|
- AndroidIntent intent = AndroidIntent(
|
|
|
- action: "android.intent.action.MAIN",
|
|
|
- package: "com.ouj.hiyd",
|
|
|
- componentName: "com.ouj.hiyd.SplashActivity_",
|
|
|
- // data: "oujgame://com.ouj.shoe",
|
|
|
- flags: [
|
|
|
- Flag.FLAG_ACTIVITY_NEW_TASK
|
|
|
- ],
|
|
|
- arguments: {
|
|
|
-
|
|
|
- });
|
|
|
- intent.launch();
|
|
|
+ startRun(context);
|
|
|
},
|
|
|
),
|
|
|
)
|