Android 没有ui的后台应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3370659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:56:06  来源:igfitidea点击:

Background application without ui

androidandroid-backup-service

提问by Mudassir

I am new to android development. I want to make one background application, so that it keeps running in background, and it's without any UI, and even its icon do not appear on desktop. In short it's a stealth application.
Is it possible?

我是安卓开发的新手。我想制作一个后台应用程序,让它一直在后台运行,而且它没有任何用户界面,甚至它的图标也不会出现在桌面上。简而言之,它是一个隐形应用程序。
是否可以?

回答by Josef Pfleger

This is certainly possible. To create an app that does not have an icon in the launch pad, just remove the Activitywith the android.intent.category.LAUNCHERcategory from the AndroidManifest.xml.

这当然是可能的。要创建不具有发射台的图标的应用程序,只是删除Activityandroid.intent.category.LAUNCHER从类别AndroidManifest.xml

To implement your background applicationit strongly depends on what you want to do. You can create a Servicefor long running tasks, BroadcastReceivers to react to specific events or Activitieswith intent filters.

要实现您的后台应用程序,它在很大程度上取决于您想要做什么。您可以Service为长时间运行的任务创建BroadcastReceivers 以响应特定事件或 Activities使用意图过滤器。

Be aware, however, that your application will be visible in both the file system and in the settings under 'Manage Applications'.

但是请注意,您的应用程序将在文件系统和“管理应用程序”下的设置中可见。

回答by Pentium10