我可以在没有活动或接收器的情况下启动服务吗? [英] Can I start a service without activity or receiver?

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

问题描述

我想在 APK 中启动一个服务.

I want to start a service in an 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

推荐答案

不,你不能.

创建一个简单的 Activity 来启动服务并简单地向用户提供一些反馈(例如告诉他们服务已经启动)并使用 MAIN/LAUNCHER 意图设置该 Activity.

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天全站免登陆