我們的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>
非常感謝。