gpt4 book ai didi

android服务导出属性?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:04:11 27 4
gpt4 key购买 nike

我是 android 平台的新手。我想导出我的服务以供公众使用。我在开发者文档上找到了一些东西

android:exportedWhether or not components of other applications can invoke the service or interact with it — "true" if they can, and "false" if not. When the value is "false", only components of the same application or applications with the same user ID can start the service or bind to it.

但是我不明白任何人都可以向我展示如何使用它的简短示例吗?

最佳答案

“导出”的目的是让其他应用程序可以访问服务。

例如\android-sdk-windows\samples\android-8\SampleSyncAdapter\AndroidManifest.xml

    <service
android:name=".authenticator.AuthenticationService"
android:exported="true">
<intent-filter>
<action
android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>
<service
android:name=".syncadapter.SyncService"
android:exported="true">
<intent-filter>
<action
android:name="android.content.SyncAdapter" />
</intent-filter>
<meta-data
android:name="android.content.SyncAdapter"
android:resource="@xml/syncadapter" />
<meta-data
android:name="android.provider.CONTACTS_STRUCTURE"
android:resource="@xml/contacts" />
</service>

然后在您的示例文件夹中找到与这些服务匹配的源代码

\android-sdk-windows\samples\android-8\SampleSyncAdapter\src\com\example\android\samplesync\authenticator\AuthenticationService.java

\android-sdk-windows\samples\android-8\SampleSyncAdapter\src\com\example\android\samplesync\syncadapter\SyncService.java

使用它的示例可能位于...

  \android-sdk-windows\samples\android-8\SampleSyncAdapter\src\com\example\android\samplesync\client\NetworkUtilities.java (3 hits)
Line 63: "https://samplesyncadapter.appspot.com";
Line 238: // Succesfully connected to the samplesyncadapter server and
Line 287: // Succesfully connected to the samplesyncadapter server and

关于android服务导出属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2944735/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com