微信多开软件系统源码,应用层多开的核心实现,Android系统多账户原理。

      微信多开有多种实现方式,一种是apk反编译修改微信包名的方式,不过这种方式会改变微信的东西,微信对这些在严格封杀。一种是利用Android的多账户原理,让微信工作在不同的用户下,就可以实现多个微信同时运行的效果。另外一种是系统层的多开,这个大家有空可以去研究下。这里我们重点介绍Android多账户,应用层多开的实现。

           话不多说,直接上代码:

 InstalledAppInfo installInfo = VirtualCore.get().getInstalledAppInfo(this.appInfo.packageName, 0);
// InstalledAppInfo installInfo = VirtualCore.get().getInstalledAppInfo(this.appInfo.packageName, 1);
 if (installInfo != null) {
     if (this.appInfo.versionCode < getPackageInfo(this.mContext, this.appInfo.packageName).versionCode) {
         Log.i("mylog", "need update!");
         isUpdate = true;
     } else {
         Log.i("mylog", "just launch !");
         showInstallAnim(false, "");
         new Thread(new Runnable() {
             public void run() {
                 Log.i("mylog", "startActivity");
                // final Intent intent = VirtualCore.get().getLaunchIntent(BaseMainActivity.this.appInfo.packageName, 0);
                 final Intent intent = VirtualCore.get().getLaunchIntent(BaseMainActivity.this.appInfo.packageName, userid);
                 try {
                     VirtualCore.get().preOpt(BaseMainActivity.this.appInfo.packageName);
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
                 VirtualCore.get().setUiCallback(intent, BaseMainActivity.this.mUiCallback);
                 try {
                     Thread.sleep(100);
                 } catch (InterruptedException e2) {
                     e2.printStackTrace();
                 }
                 BaseMainActivity.this.mContext.runOnUiThread(new Runnable() {
                     public void run() {
                         //VActivityManager.get().startActivity(intent, 0);
                         VActivityManager.get().startActivity(intent, userid);
                         BaseMainActivity.this.overridePendingTransition(0, 0);
                         Log.i("mylog", "finish");
                         BaseMainActivity.this.finish();
                     }
                 });
             }
         }).start();
         return;
     }
 }
 if (installInfo == null || isUpdate) {
     Log.i("mylog", "install or update !");
     new Thread(new Runnable() {
         public void run() {
             ApplicationInfo ai = BaseMainActivity.getPackageInfo(BaseMainActivity.this.mContext, BaseMainActivity.this.appInfo.packageName).applicationInfo;
             String sourceDir = ai.publicSourceDir != null ? ai.publicSourceDir : ai.sourceDir;
             if (sourceDir.equals("")) {
                 BaseMainActivity.this.showInstallError("请安装官方微信");
                 return;
             }
            // VUserInfo newUserInfo = VUserManager.get().createUser(nextUserName, VUserInfo.FLAG_ADMIN);

             InstallResult result = VirtualCore.get().installPackage(sourceDir, 4);
             //InstalledAppInfo installedAppInfo = VirtualCore.get().getInstalledAppInfo("com.tencent.mm", 0);

             //boolean success = VirtualCore.get().installPackageAsUser(nextUserId, info.packageName);
             if (result.isSuccess) {
                 for(int k=0;k<=userid;k++)
                 {
                     VUserInfo newUserInfo = VUserManager.get().createUser("Space "+k, VUserInfo.FLAG_ADMIN);
                 }
                 boolean result11 = VirtualCore.get().installPackageAsUser(userid, "com.tencent.mm");
               // final Intent intent = VirtualCore.get().getLaunchIntent(BaseMainActivity.this.appInfo.packageName, 0);

             final Intent intent = VirtualCore.get().getLaunchIntent(BaseMainActivity.this.appInfo.packageName, userid);
             try {
                 VirtualCore.get().preOpt(BaseMainActivity.this.appInfo.packageName);
             } catch (Exception e) {
                 e.printStackTrace();
             }
                 VirtualCore.get().setUiCallback(intent, BaseMainActivity.this.mUiCallback);
                 BaseMainActivity.this.mContext.runOnUiThread(new Runnable() {
                     public void run() {
                         //VActivityManager.get().startActivity(intent, 0);
                         VActivityManager.get().startActivity(intent, userid);
                         BaseMainActivity.this.overridePendingTransition(0, 0);
                         BaseMainActivity.this.finish();
                     }
                 });
                 BaseMainActivity.this.appInfo.versionCode = BaseMainActivity.getPackageInfo(BaseMainActivity.this.mContext, BaseMainActivity.this.appInfo.packageName).versionCode;
                 BaseMainActivity.this.appInfo.path = sourceDir;
                 AppInfoDbHelper.saveAppInfo(BaseMainActivity.this.mContext, BaseMainActivity.this.appInfo);
                 return;
             }
             //Log.e("mylog", "install error-->" + result.error);
             BaseMainActivity.this.showInstallError("安装失败");
         }
     }).start();
     showInstallAnim(true, "正在启动...");
在这里我们有用到Android多账户,利用多个账户空间进行隔离达到同时运行多个微信的目的。有需要代码或者需要定制开发的请加威信:393231639。

你可能感兴趣的:(云控系统)