仅平铺应用程序

Tile only application

已经看到关于没有 GUI 的活动的问题 here, here and here。另外,这些回答都比较老了,不知道还有没有用。

我想创建一个应用程序,其唯一的用户交互是快速磁贴。

我知道根本不可能没有 activity,所以我有一个空白的 activity,没有使用 @android:style/Theme.NoDisplay

的显示
<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoDisplay">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

<service
    android:name=".AdaptativeSleepTile"
    android:icon="@drawable/ic_launcher_background">
</service>

但是这个应用出现在我的应用列表中(我点击它时没有任何反应,逻辑上),这不是this answer.

评论中写的

我无法删除行 <category android:name="android.intent.category.LAUNCHER"/> 否则我会收到错误消息

Could not identify launch activity: Default Activity not found
Error while Launching activity

那么我应该怎么做才能获得唯一的用户交互是快速磁贴的服务? (同样的问题也适用于完全没有交互,或者我猜只有小部件)

使用 Android Studio 4 和 SDK 29

I want to create an app for which the only user interaction is a quick tile.

这可能实用也可能不实用。自 Android 3.1 起,应用程序以“停止状态”安装,需要显式 Intent 才能将它们移出停止状态并允许它们进入 运行。通常,这来自用户点击启动器中的图标以 运行 您的 MAIN/LAUNCHER activity.

可能只需在清单中提供一个 TileService 就足以让您在通知栏中列出,并且添加磁贴的行为足以将您的应用从停止状态中移出状态。但是,我当然不能保证,如果这不起作用,我也不会感到惊讶。

此外,请记住您可能出于其他原因需要 activity:

  • 显示您的服务条款
  • 显示您的隐私政策
  • 提供技术支持
  • 允许配置应用程序
  • 以此类推

But the app appears in my app list (with nothing happening when I click it, logically), which is not what is written in the comments of this answer.

如果您指的是第一条评论,那完全是错误的,正如对该答案的其他评论所指出的那样。

I can't remove the line otherwise I get the error message

我假设您是从 Android Studio 获得的。您将需要更改 运行 配置以不尝试启动 activity.

Same question would also apply for no interaction at all

幸运的是,没有解决方案。恶意软件作者认为完全不可见的应用程序 很棒 ,并且 Android 采取措施阻止此类应用程序运行。而且,这就是为什么如果您的 TileService.

需要 activity 我不会感到惊讶的原因