gpt4 book ai didi

android - 如何从 fragment 开始服务

转载 作者:IT老高 更新时间:2023-10-28 22:00:14 25 4
gpt4 key购买 nike

我想从 ListView 项的 fragment 开始服务。我正在尝试通过以下方式调用服务:

startService(new Intent(getActivity(),myPlayService.class));

但它根本不起作用。我如何从 fragment 中调用我的服务?有没有其他方式启动服务?

最佳答案

替换

startService(new Intent(getActivity(),myPlayService.class));

getActivity().startService(new Intent(getActivity(),myPlayService.class));

关于android - 如何从 fragment 开始服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13007355/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com