是否可以使apk没有任何活动? [英] Is it possible to make an apk with no activity?

查看:113
本文介绍了是否可以使apk没有任何活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以制作仅提供服务的apk吗?

Can I make an apk that only has a service?

我正在尝试提供长期运行的服务,该服务位于后台并更新数据库.没有用户界面.

I'm trying to make a long running service that sits in the back and updates a database. No UI.

我一直认为必须将服务引导至活动才能创建APK,但这是真的吗?

I always thought that a Service had to be bootstrapped to an Activity in order to make an APK but is that true?

推荐答案

可以,但是可能会有问题. Google禁止应用通过操作"(用户的某些行为)启动活动.

You can, but you might have problems. Google prohibits an app from starting an Activity with an "action" - something from the user.

请参阅此帖子:如何在安装时启动android服务

可能会捕获该帖子中建议的与您的"活动无关的用户操作,如下所示:

It may be possible to capture a user action not related to "your" activity, as suggested in that post and like this:

我可以在没有活动或接收者的情况下启动服务吗?/a>

Can I start a service without activity or receiver?

但是,我可以确定,上次检查时,Android的启动服务"部分要求显示用户可见的活动.否则,可能会发生恶意活动,而用户不会意识到应用程序已经安装或确认.

However, I'm pretty sure that the last time I checked, the "start service" portion of Android required a user-visible activity to be displayed. Otherwise, malicious activities may occur without the user recognizing that an app was even installed or acknowledged.

这篇关于是否可以使apk没有任何活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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