我可以启动一个服务没有活动或接收器? [英] Can I start a service without activity or receiver?

查看:148
本文介绍了我可以启动一个服务没有活动或接收器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 APK 启动服务。

我想如下使用:

<application android:icon="@drawable/icon" android:label="@string/app_name">  
        <service android:name =".TestServcie">  
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />  
                <category android:name="android.intent.category.LAUNCHER" />  
            </intent-filter>  
        </service>  
    </application>

任何想法?
谢谢

Any ideas?
Thanks

推荐答案

没有你不行。

创建一个简单的活动而启动该服务,只是提供了一些反馈给用户(告诉他们的服务已经启动为例),并设置活动主/ LAUNCHER意图。

Create a simple Activity which starts the service and simply provides some feedback to the user (to tell them the service has started for example) and set that Activity with the MAIN/LAUNCHER intent.

这篇关于我可以启动一个服务没有活动或接收器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆