您当前的位置: 首页 > 
  • 1浏览

    0关注

    674博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

service显示启动和隐式启动

沙漠一只雕得儿得儿 发布时间:2019-05-14 14:37:01 ,浏览量:1

隐式启动:(通过设置包名和action启动) component代码需要添加包名和service名:
            Intent intent = new Intent();
            ComponentName componentName = new ComponentName(getPackageName(), "com.example.testservices.TestService");
            intent.setComponent(componentName);
            startService(intent);
对应的manifes代码,需要添加action:
        

            
                
            

        

 

显示启动: java代码直接指明启动的service:
Intent intent = new Intent(this, TestService.class);
startService(intent);
AndroidManifest代码不需要特殊配置:
        
        

可以参考博客:https://blog.csdn.net/liuyi1207164339/article/details/51711435

关注
打赏
1657159701
查看更多评论
立即登录/注册

微信扫码登录

0.0370s