我在Android服务def中做错了什么,它不是可见服务?

时间:2011-10-23 18:44:45

标签: android service android-manifest manual

我有一个Android服务mycompany.service.Agent。这是应用程序中唯一定义的内容。它是“开始”型服务。

我能够在Emulator上构建并安装它就好了。我通过转到设置应用的“管理应用”部分来验证它。

我没有任何活动来启动此服务。 我正尝试从adb shell手动启动它。

am startservice mycompany.service.STARTAGENT

启动服务:Intent {act = android.intent.action.VIEW dat = mycompany.service.STARTAGENT} 错误:未找到;没有服务开始。

以下是我的清单文件的副本。 我做错了什么?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="polycom.service"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:label="@string/app_name" android:icon="@drawable/icon">
        <service android:name=".APIAgent" android:exported="true" >
            <intent-filter>
                <action android:name="mycompany.service.STARTAGENT" />
                <action android:name="mycompany.service.STOPAGENT" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>            
        </service>
    </application>
</manifest> 

感谢
视频专家

1 个答案:

答案 0 :(得分:3)

我很蠢。我应该先阅读文档。

这是应该如何调用

am startservice -a mycompany.service.STARTAGENT

我错过了“-a”部分。

相关问题