我们的android系统支持多用户功能。我想从其他应用程序启动我的服务器,例如使用命令startService(intent)的app1,app2。 根据谷歌的文档https://source.android.com/devices/tech/admin/multiuser-apps.html。 我需要设置android:singleUser =“true”来确保我的服务只在多个用户的android系统中的一个实例中运行。但是当我在其他应用程序startservice,我有以下异常:如何让我的服务仅在多用户android系统中的一个实例中运行?
Not allowed to start service Intent { act=com.xx.xxx.action.Start pkg=com.xx.xxx (has extras) } without permission not exported from uid 1000
似乎机器人:出口=“真”是由Android禁用:单用户=“真”。如果我没有添加android:singleUser =“true”,它运行良好,但我的服务在后台运行的实例不止一个。 我的问题是如何让我的服务只能在其他应用程序中使用startService(intent)在单个实例中运行? 我的Manifest.xml的配置如下:
<application
android:name=".App"
android:label="@string/app_name"
android:directBootAware="true"
android:multiprocess="false"
android:persistent="true">
<service
android:name=".MyService"
android:singleUser="true"
android:exported="true"
android:permission="com.xx.permission.xx">
<intent-filter>
<action android:name="com.xx.xx.action.xx" />
</intent-filter>
</service>
</Application>
非常感谢。