我从 MainActivity
和 Fragment
启动后台服务。
它会创建重复的线程吗?那么这将是 2 个服务在运行?
主要 Activity
protected void onCreate(Bundle savedInstanceState) {
//...
context.startService(new Intent(context,gps_service.class));
//...
fragment
public class FragmentThree extends Fragment {
//... Click method of the button calls
getActivity().startService(new Intent(getActivity(),gps_service.class));
最佳答案
Will it create duplicate threads? So It will be 2 services running?
否只会启动一项服务并且只会运行一项服务
关于java - 是否从 MainActivity 和 fragment 复制线程启动服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47864492/