Git Product home page Git Product logo

Comments (6)

VenusCao avatar VenusCao commented on June 2, 2024

先拿权限再init

from x5_webview_flutter.

songjiabin avatar songjiabin commented on June 2, 2024

好的,谢谢。
还有另外一个问题:
有没有一个方法知道 我已经初始化成功了。某种场景下我会触发再次初始化操作,这个时候会导致卡死没反应。

from x5_webview_flutter.

VenusCao avatar VenusCao commented on June 2, 2024

只能init一次,重新init必须重启app

from x5_webview_flutter.

songjiabin avatar songjiabin commented on June 2, 2024

当我切换账户,登录其他账户的话。这个时候还会走init方法,就会导致上面的问题。有什么好的解决方案吗?

from x5_webview_flutter.

VenusCao avatar VenusCao commented on June 2, 2024

用法可以看example,基本都找得到

  void loadX5() async {
    if (isLoad) {
      showMsg("你已经加载过x5内核了,如果需要重新加载,请重启");
      return;
    }

    //请求动态权限,6.0安卓及以上必有
    Map<Permission, PermissionStatus> statuses = await [
      Permission.phone,
      Permission.storage,
    ].request();
    //判断权限
    if (!(statuses[Permission.phone].isGranted &&
        statuses[Permission.storage].isGranted)) {
      showDialog(
          context: context,
          builder: (context) {
            return AlertDialog(
              content: Text("请同意所有权限后再尝试加载X5"),
              actions: [
                FlatButton(
                    onPressed: () {
                      Navigator.pop(context);
                    },
                    child: Text("取消")),
                FlatButton(
                    onPressed: () {
                      Navigator.pop(context);
                      loadX5();
                    },
                    child: Text("再次加载")),
                FlatButton(
                    onPressed: () {
                      Navigator.pop(context);
                      openAppSettings();
                    },
                    child: Text("打开设置页面")),
              ],
            );
          });
      return;
    }

    //没有x5内核,是否在非wifi模式下载内核。默认false
    await X5Sdk.setDownloadWithoutWifi(true);

    //内核下载安装监听
    await X5Sdk.setX5SdkListener(X5SdkListener(onInstallFinish: () {
      print("X5内核安装完成");
    }, onDownloadFinish: () {
      print("X5内核下载完成");
    }, onDownloadProgress: (int progress) {
      print("X5内核下载中---$progress%");
    }));
    print("----开始加载内核----");
    var isOk = await X5Sdk.init();
    print(isOk ? "X5内核成功加载" : "X5内核加载失败");

    var x5CrashInfo = await X5Sdk.getCrashInfo();
    print(x5CrashInfo);
    if(isOk){
      x5CrashInfo="tbs_core_version" + x5CrashInfo.split("tbs_core_version")[1];
    }
    setState(() {
      isLoadOk=isOk;
      crashInfo = x5CrashInfo;
    });

    isLoad = true;
  }

from x5_webview_flutter.

songjiabin avatar songjiabin commented on June 2, 2024

好的 我再看下

from x5_webview_flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.