Smobiler上海石磨_.NET移动开发平台

标题: 打开微信错误 [打印本页]

作者: linyan    时间: 2020-1-15 15:53
标题: 打开微信错误
本帖最后由 linyan 于 2020-1-15 19:20 编辑

打开微信时发生错误,不知是何原因引起的。
private void button1_Press(object sender, EventArgs e)
        {
            AndroidCodeProvider provider = new AndroidCodeProvider();
            provider.Imports.Add("android.content.Intent");
            provider.Imports.Add("android.content.ComponentName");
            //打开不同的应用
            //微信  com.tencent.mm         com.tencent.mm.ui.LauncherUI
            //QQ    com.tencent.mobileqq   com.tencent.mobileqq.activity.HomeActivity
            provider.MethodBody = @"
                Intent intent = new Intent();
                ComponentName cmp = new ComponentName(""com.tencent.mm"",""com.tencent.mm.ui.LauncherUI"");
                intent.setAction(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_LAUNCHER);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                intent.setComponent(cmp);
                activity.startActivity(intent);";
            this.androidCodeCompiler1.Run(provider, (obj, args) =>
            {
                if (args.isError == true)
                    MessageBox.Show(args.error);
                else
                    Toast("打开微信成功");
            });
        }


作者: linyan    时间: 2020-1-16 06:21
本帖最后由 linyan 于 2020-1-16 06:39 编辑

问题已解决,在打包插件中添加动态编译。D:\ABC.jpg




欢迎光临 Smobiler上海石磨_.NET移动开发平台 (https://www.smobiler.com/) Powered by Discuz! X3.2