首页 > 解决方案 > 当应用程序从堆栈中终止时,后台服务停止

问题描述

当应用程序从堆栈中被杀死时,后台服务停止

public int onStartCommand(Intent intent, int flags, int startId) {

    googleApiClient = new GoogleApiClient.Builder(getApplicationContext())
                    .addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this)
                    .addApi(LocationServices.API)
                    .build();

    return START_STICKY;
    }

标签: javaandroid

解决方案


没有直接的解决方案,但下面的链接中提到了解决方法,

https://stackoverflow.com/a/58162451/7579041

上面的链接适用于库存 ROM 和自定义 ROM 设备,如 OnePlus、OPPO、VIVO 等

我希望这会帮助你


推荐阅读