繁体   English   中英

在China Phone中刷新应用程序后台服务已停止

[英]Application background service stopped when swiped up in China Phone

当应用程序被刷上(关闭),后台服务停止运行时,我一直在寻找有关中国手机(Oppo,华为,小米,Vivo等)此问题的答案。

大多数解决方案是:

  1. 包括START_STICKY并使用AlarmManager启动服务。
  2. 以编程方式将用户引导至自动启动管理器以按用户启用应用程序。
  3. 手动将我的应用从省电模式中排除,或将我的应用包含在受保护的应用中。

我的问题是像Whatsapp这样的应用程序如何仍然收到消息或通知甚至刷过? 此外,如果手机重启,1和2中提到的解决方案不起作用,但Whatsapp如何仍能接收消息? 我测试了三星设备,即使应用程序被刷了,他们也可以运行后台服务。 有没有人面对中国手机的同样问题?

try {
            Intent intent = new Intent();
            String manufacturer = android.os.Build.MANUFACTURER;
            if ("xiaomi".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
            } else if ("oppo".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
            } else if ("vivo".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
            } else if ("oneplus".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.oneplus.security", "com.oneplus.security.chainlaunch.view.ChainLaunchAppListAct‌​ivity"));
            } else if ("Letv".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
            } else if ("Honor".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
            }
            else if ("huawei".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
            }
            else if ("asus".equalsIgnoreCase(manufacturer)) {
                intent.setComponent(new ComponentName("com.asus.mobilemanager","com.asus.mobilemanager.autostart.AutoStartActivity"));
            }
            else {
                Log.e("other phone ", "===>");
            }
            List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
            if (list.size() > 0) {
                startActivity(intent);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

我仍在寻找答案。 我已与Google支持小组联系,他们回复如下:

在与我们的工程师讨论后,这确实是预期的行为。 因为他们使用了一个库存ROM来禁用重新启动大多数应用程序的后台服务。 用户应手动启用后台服务的自动启动,因为它们在默认情况下处于禁用状态。 无法以编程方式为所有设备启用此功能。 因此,您必须提示用户手动执行这些步骤。 请查看本指南以了解有关此变通方法的更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM