Is it possible to make an apk with no activity?

China☆狼群 提交于 2020-01-05 07:37:01

问题


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.

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


回答1:


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

See this post: How to start android service on installation

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

Can I start a service without activity or receiver?

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.



来源:https://stackoverflow.com/questions/27256324/is-it-possible-to-make-an-apk-with-no-activity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!