Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
AndroidManifest.xml
根本不包括<intent-filter>. 然后,您的服务将只能由您的应用程序中的组件访问。您将使用显式Intent与其交互(例如,new Intent(this, MyPrivateService.class))。
<intent-filter>
Intent
new Intent(this, MyPrivateService.class)
正如 commonsware 所说,这是一个很好的答案。您也可以在清单中这样做:
android:exported="false"