安卓:
public class LocationService extends Service {
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
startActivity(new Intent(this, activity.class));
}
}
我从 Activity
启动了这项服务
在 Activity
如果条件满足开始
startService(new Intent(WozzonActivity.this, LocationService.class));
从我的 LocationService
上面提到的无法启动 Activity
,我怎样才能获得当前运行的上下文 Activity
在服务类?
原文由 d-man 发布,翻译遵循 CC BY-SA 4.0 许可协议
从服务类内部:
但是,由于电池优化限制,这不适
Android 10
+